Basic JavaScript - Generate Random Whole Numbers with JavaScript

Tell us what’s happening:

Describe your issue in detail here.
Please tell me what is wrong her…

Your code so far

function randomWholeNum() {
  Math.floor(Math.random() * 10);
  return Math.random();
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36

Challenge Information:

Basic JavaScript - Generate Random Whole Numbers with JavaScript

You are just calling this and not doing anything with the value it returns. It seems like you would want to return its value from the function since that’s what the instructions are asking you to do.

The result of randomWholeNum should be a whole number.

The above text is what i keep getting when i run the test

That’s because your current return statement is:

return Math.random();

And since Math.random() does not return a whole number then your function is not returning a whole number.

The function call you are making above the return statement does return a whole number. Don’t you think that’s the value you want to return?

Hey
You need to create another variable to store the results then return the variable

function add(a,b){
let sum= a+b;
return sum
}

hope it gives you the Idea of what you are supposed to do

You can use a temporary variable but it is not required. This can be solved with just a single return statement.

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