Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialOsaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 PointsHow can I get my codes to run?
function getRandomNumber( upper ){ var randomNumber = Math.floor( Math.round() * upper ) + 1; return randomNumber; } console.log( getRandomNumber(10) );
When I run the code from my workspace unto the browser, I then check the JavaScript console only to see error "NaN" on random.js: 5 i.e the console.log line
1 Answer
Osaro Igbinovia
Full Stack JavaScript Techdegree Student 15,928 PointsThank you Charlie, I thought I typed in Math.random()
Charlie Gallentine
12,092 PointsCharlie Gallentine
12,092 PointsIt looks like you never called Math.random(), instead you have Math.round() which your Math.floor() is already taking care of.