Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 12-02-2004, 03:06 PM   #1 (permalink)
NX5
 
Newb Techie

Join Date: Sep 2004

Posts: 20

NX5

Question n00b question: for loops

Hi

This question must have been asked by every single newbie everywhere! I really don't get for loops. I'm talking about in JavaScript here. Can anyone explain it to me in simple language?

Thanks
NX5 is offline  
Old 12-02-2004, 10:44 PM   #2 (permalink)
 
Newb Techie

Join Date: Nov 2004

Posts: 28

Windwaker222

Default

A loop is a function or whatever you would like to call it

It will repeat itself until until the condition is met or it is exited

example : a loop could be from 1 to 10. It will print out, or do whatever function you tell it to do untill it reaches 10. Then it exits the loop

start loop
1: test
2: test
3: test
4: test
5: test
6: test
7: test
8: test
9: test
10: test
exit loop(the condition had been met..has arrived at 10)

There is many different kinds of loops but they mainly function in the same way.
Windwaker222 is offline  
Old 12-02-2004, 11:26 PM   #3 (permalink)
 
Monster Techie

Join Date: Aug 2004

Posts: 1,622

U-Toast

Default

take this for example

int i;
for (i=0; i<15; i++)
{
system.out.println(i);
system.out.println();
}
this would print out
0
1
2
...
15
the i= is wat i starts at. The i< is wat it finishes, and I++ mean it add 1 each time.
and itl repeat the loop till it reaches the number that is befor <
__________________
My current specs:
i7 920
Biostar TPower x58
3x2GB g.skill
XFI GTX260 Black Edition
640 WD Caviar Black
Vista Home Premium x64
U-Toast is offline  
Old 12-13-2004, 10:22 PM   #4 (permalink)
 
Newb Techie

Join Date: Dec 2004

Posts: 10

mrprimo55

Default

that would actually only go until 14. to print out the 15 it would have to be for (i=0;i<=15;i++)
mrprimo55 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On