A 'for' loop takes 3 arguments (initialize; test; increment). The 'test'
must equate as true or false
This doesn't work...
x = 5;
for (y=1; (y==5); y+=1) {
alert(x * y);
}
...nor does...
x = 5;
for (y=1; (y===5); y+=1) {
alert(x * y);
}
....but this does..
x = 5;
for (y=1; (y<6); y+=1) {
alert(x * y);
}
Why do the first two fail? If i is value 5 then i==5 is true, as is
i===5.
Can anyone explain what I'm missing here?
Regards
must equate as true or false
This doesn't work...
x = 5;
for (y=1; (y==5); y+=1) {
alert(x * y);
}
...nor does...
x = 5;
for (y=1; (y===5); y+=1) {
alert(x * y);
}
....but this does..
x = 5;
for (y=1; (y<6); y+=1) {
alert(x * y);
}
Why do the first two fail? If i is value 5 then i==5 is true, as is
i===5.
Can anyone explain what I'm missing here?
Regards
Comment