+ 12
can you answer what is the difference among the three nearly same code? (good explanation please)
for (var x=1; x<=5; x++) { x=x+10; document.write(x); } //output:11 for (var y=1; y<=5; y++) { document.write("<br>"+y); y=y+10; } //output:1 for(var z=1;z<=5;z++){ z=z+10; } document.write("<br>"+z); //output:12
4 Respuestas
+ 14
but the output of 2nd code is //1, how it increments??? :O
code3 is 12, because document.write is outside the loop? & code 1 was inside of curly brackets??
+ 14
oh Right :)
+ 7
1. It adds x by 10 then prints it.
2. It prints y with a new line. Then it increments it by 10.
3. It adds z by 10. Then increment it by one after the iteration. Then it prints it out with a new line at the beginning.
+ 7
Because it prints it first, then adds it.