- 1

There is a wrong answer.

In Module 3 Quiz of Conditional and Loops, the first question is expectating a wrong answer. The true answer is 5 (because it's while x less than 6 = 5) and the question is expectating the answer 6, but it isn't less or equal.

12th Jan 2019, 1:38 PM
Davi Melo
Davi Melo - avatar
2 Réponses
+ 6
What language. I'm assuming the JS course since the description matches. while (x < 6) { x++; } document.write(x) The answer is 6. The loop terminates when x is no longer smaller than 6, i.e. when x is 6.
12th Jan 2019, 1:45 PM
Hatsy Rei
Hatsy Rei - avatar
+ 5
Adding a point to Hatsy Rei s description. As you thought the loop is running until x = 5. But what happens next?Lets take a look at it. if(x<6) //true, x is 5{ x++ //increments x, making it 6 } document.write(x) //6 So 6 is the correct answer.
12th Jan 2019, 4:47 PM
Seniru
Seniru - avatar