I just posted a doubt I had on a break statement exercise that was a more advanced version of this one. It just so happens that it gives the same error in this one and I don’t know how to go around it
Any thoughts?
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.
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');
This gives 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
It seems a bit foolish that “assign, assign, newline, log, log” wouldn’t be acceptable. But I guess you need to be human to comprehend the code. At least my guess is that to help prevent false OKs the “evaluating code” is extremely strict. i.e. not a line below but the line below.
Try following the “rule” explicitly
var target = Math.floor(Math.random() * 11);
console.log("Target is " +target);
var guess = Math.floor(Math.random() * 11);
console.log("First guess is " +guess);
Yes, it’s like DaveMaxwell said, my code interpreter apparently is not very smart and it only accepts a specific path. If it weren’t for him I’d still be banging my walls out of frustration
I can’t, these are exercises I need to do in order to enter an intensive bootcamp to be a fullstack developer It’s all part of their process, I have 2 days to do 59 exercises like this so I can enter. So far, it’s not going great
Perhaps you have missed the real point
of “their” tests.
“Their” real test is probably to see if you
are observant enough to to see that “their
code interpreter” is flawed and to then
draw “their” attention to this anomaly.
One thing, if I have any other questions like this should I open another thread or keep it in this one and edit the title? I don’t want to flood the forum with questions like these
When in doubt it’s always best to start a new thread.
We don’t want people to have to wade through hundred of comments that are unrelated to what you’re wanting to know. You can always supply a link from the new thread to related ones, if need be.