the while loop question in JS | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

the while loop question in JS

hello, yes I am a noob , just started to learn JS, and I am stuck, looking for some help please. so the question on while loop. It's fill in the blanks. i got the first 2 right it's the 3rd I stuck on. And I have tried to work it out and still can not get it . it's asking x= +1 ( the space is what I should fill in, ( I have put the code on the bottom) many thanks var x = 1; while (x <= 5 ) { document.write(x + "<br />"); x = + 1; }

30th Apr 2021, 4:37 PM
shycoo
4 Answers
+ 3
That's ok. You want to assign a new value to x by using x = ..? statement. If you put x in the space, you will get x = x + 1 This means that the value on the right-hand side of the = is 1 more than the current value of x. Thus, x will be increased by 1.
30th Apr 2021, 5:11 PM
Russ
Russ - avatar
+ 1
Hi Russ, that's great I understand were I was look at the Number that X is and I thought I had to put a number. thank you so much.
30th Apr 2021, 5:20 PM
shycoo
0
You have to increment x so that you don't get an infinite loop. Do you know how to do that?
30th Apr 2021, 4:57 PM
Russ
Russ - avatar
0
Hello Russ, thank you for your reply, and my answer is no I do not.
30th Apr 2021, 5:02 PM
shycoo