0
Can someone help me? I have a question about loops
Fill in the blanks to prints EVEN values from 0 to 20 using a for loop var x = 0; for (; x <= ___ ; x += ___ ) { document.write(x); } Its 20 and 2 but can someone explain me [in a simpler] way i can't understand.
6 Respostas
+ 9
Duarte Paixão
It would be great if you frame your query in description.
Just edit your question!
So that everyone can see your query above only.
Hope you will do it. 👍
Thanks
+ 3
it means that first x is 0
Then we make a for loop in which we increase the value of x each time by 2 so that it goes like this:
0 2 4 6 8 10 and eventually stop at 20
for (let x = 0; x <= 20; x += 2) {
}
+ 2
You need to understand the three elements of this for-loop.
for (<integer start value>; <until integer exit criteria>; <steps to do for each iteration>) { <body> }
Until: 20 - clear?
Step: 2 - every second (x + 2) value -> even numbers, clear?
+ 2
Thanks already understand, thanks for help
+ 1
Fill in the blanks to prints EVEN values from 0 to 20 using a for loop
var x = 0;
for (; x <= ___ ; x += ___ ) {
document.write(x);
}
Its 20 and 2 but can someone explain me way i can't understand.
0
Can someone help me?