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.

11th Aug 2020, 4:28 PM
Duarte Paixão
Duarte Paixão - avatar
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
11th Aug 2020, 4:33 PM
Piyush
Piyush - avatar
+ 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) { }
11th Aug 2020, 4:48 PM
maf
maf - avatar
+ 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?
11th Aug 2020, 4:44 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Thanks already understand, thanks for help
12th Aug 2020, 7:11 AM
Duarte Paixão
Duarte Paixão - avatar
+ 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.
11th Aug 2020, 4:34 PM
Duarte Paixão
Duarte Paixão - avatar
0
Can someone help me?
11th Aug 2020, 4:29 PM
Duarte Paixão
Duarte Paixão - avatar