I.
ex. 1
var x = 0;
while (x<5){
console.log(x);
x=x+1;
}
The console will print out x as the numbers 0,1,2,3, and 4 because the while is adding +1 every time until the statement is not true x<5
ex 2:
var x = 0;
var y = 5;
while (x<5){
console.log(x+y);
x=x+1;
The console will print out numbers 5,6,7,8 and 9
Comments