What's wrong with my code? while loop, Math.random


#1


https://www.codecademy.com/courses/javascript-beginner-en-ASGIv/2/4?curriculum_id=506324b3a7dffd00020bf661


The while loop just doesn't work. I don't know what's wrong with the syntax, I'm not able to find out how to use the condition variable.


var condition = Math.floor(Math.random());

while (condition === 1) {
    console.log("Kopf");
    condition = Math.floor(Math.random());
}
console.log("Zahl")


#2

i think you should change the condition in while loop " condition = Math.floor(Math.random());"
because we put that condition there for stop the while loop. but you are put the same condition in starting also. it should not be!


#3

I don't understand that. So I should put the var into the loop or not?


#4

put var inside the condition


#5

put var inside condition of while loop


#6

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.