ex. 1
var x = 0;
while (x<5){
console.log(x);
x=x+1;
}
Example 1 is 0 1 2 3 4 because if it were to do numbers 5 and up it would be a false statement.
ex 2:
var x = 0;
var y = 5;
while (x<5){
console.log(x+y);
x=x+1;
Example 2 is 5 6 7 8 9 because in order for the statement to be true the numbers has to be 5 and higher.
Comments