I'm working on a java course but having some troubles with a question The question is " Your editor currently has a variable declared target to which a random number between 0 and 10 will be assigned. Print it to the console. Under it write a small program which will keep guessing numbers and attributing them to the variable guess and printing them until the number guessed is the same as the target. " My code is for now: ```` var target = Math.floor(Math.random() * 11); var guess = Math.floor(Math.random() * 11); console.log("Target is " +target); console.log("First guess is " +guess); while (guess!==target) { guess = Math.floor(Math.random() * 11); console.log('New guess is '+guess); } console.log('Yay! You\'ve done it, '+guess +' is right'); Code (javascript): ```` The editor is returning the error: >>>>Code is incorrect Make you you're printing the value of guess to the console in the line below assigning it a new value Target is 4 First guess is 8 New guess is 2 New guess is 10 New guess is 0 New guess is 10 New guess is 6 New guess is 2 New guess is 0 New guess is 4 Yay! You've done it, 4 is right Can somebody tell me if my code is good and if not what i must change to get it working?
What "editor"? Why would your editor be telling you whether the code is correct or not? If it is, go find an ACTUAL editor and not some goofy "tool" You might also want to look at do/while instead of while{}. It may better fit this task. Also, if it's supposed to be BETWEEN 0 and 10, shouldn't it be guessing 1..9?
You are asking your question in the WRONG forum. This forum is for JavaSCRIPT questions NOT Java questions. Likely FEW if ANY people here can answer your question.
Looks like Javascript to me and I'm guessing the homework assignment wanted to see a while being used. I'd submit that, it looks fine.