Tell us what’s happening:
I broke up the code into more steps to be able to see what I was doing, but my compiler says that I need to multiply by 10 to get a whole number. How is
var randomNum = Math.random() * 10;
differnet from
var randomNum = Math.random();
randomNum *= 10;
**Your code so far**
function randomWholeNum() {
// Only change code below this line
var randomNum = Math.random();
randomNum *= 10;
var wholeNum = Math.floor(randomNum);
return wholeNum;
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Generate Random Whole Numbers with JavaScript
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Yeah, this looks to be a limitation on the test evaluator. Your code with random *= 10 should be correct, but it appears that the evaluator is looking for * 10 on the same line as the Math.random()