Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

# Generate Random Whole Numbers with JavaScript

See original GitHub issue

What have I done wrong? Can someone help me in order to continue? Thank you in advance My code:

``````var randomNumberBetween0and19 = Math.floor(Math.random() * 20);

function myFunction() {

// Only change code below this line.
var randomNumberBetween0and9 = Math.floor(Math.random() * 10);
return Math.random();
// Only change code above this line.
}

``````

### Issue Analytics

• State:
• Created 8 years ago

1reaction

return randomNumberBetween0and9;

0reactions
wangaricommented, Apr 8, 2017

return randomNumberBetween0and9

Or check Out this removed solution by mod

#### Top Results From Across the Web

Generate Random Whole Numbers with JavaScript - GitHub
Generate Random Whole Numbers with JavaScript · Use Math.random() to generate a random decimal. · Multiply that random decimal by 20. · Use...
Generating random whole numbers in JavaScript in a specific ...
Math.random() returns a number between 0 (inclusive) and 1 (exclusive). We multiply this number by the range (max-min).
Generate Random Whole Numbers with JavaScript - Guide
We need to use Math.floor() with Math.random() to generate and return a random whole number between 0 and 9. · Putting Math.floor() and...
How to Create a Random Whole Number in JavaScript
Step 1: generating a random number · Step 2: multiply by 20 · Step 3: remove the decimal places · Step 4: elevate...
JavaScript Random - W3Schools
Math.random() used with Math.floor() can be used to return random integers. There is no such thing as JavaScript integers. We are talking about...

#### Troubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free