New course! Every coder should learn Generative AI!
Try a free lesson+ 10
Here's a developer's question
How can the code below which was written in Python be written in JavaScript? x = 111 for i in range(5): x= x+2 print(x) x= x+4 print (x)
5 Answers
+ 11
var x = 111;
for(var i = 0; i < 5; ++i) {
x += 2;
console.log(x);
x += 4;
console.log(x);
}
+ 7
Anna, why is it that the code does not create an infinite loop, thus stopping at some certain number
+ 4
var x = 111
for (var i = 0; i < 5; i++) {
x += 2
document.write(x) // or console.log(x)
document.write("<br/>")
x += 4
document.write(x)
document.write("<br/>")
}
+ 3
The code from Anna stops when i == 5 making thr statement in the middle ( i<5) false