Basic JavaScript - Generate Random Whole Numbers with JavaScript

Why does this code not show a whole number as a result unless I use return?

function randomWholeNum() {


Math.floor(Math.random() * 10);

}

Challenge: Basic JavaScript - Generate Random Whole Numbers with JavaScript

Link to the challenge:

Yes. A return statement is the way you pass a value back out of the function.

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