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 trial

JavaScript JavaScript Basics (Retired) Working With Numbers The Random Challenge Solution

Jeremy Barbe
Jeremy Barbe
8,728 Points

I don't see any variation

I'm not sure how to include workspace snapshots but i've scanned over my code and don't see anything different from what he's doing in the video. What's the issue?

var input = prompt("gimme a number");
var interger = parseInt(input);
var random = math.floor(Math.random() * interger) + 1;

var message = "<p>" + random + " is the magic number.</p>";

document.write(message);

2 Answers

Neil Docherty
Neil Docherty
10,418 Points

Checking the console we see an error: "Uncaught ReferenceError: math is not defined".

This show us that you've just made a typo. Missing uppercase 'M'.

Your code:

var random = math.floor(Math.random() * interger) + 1;

Correction:

var random = Math.floor(Math.random() * interger) + 1;
Christopher Vesti
Christopher Vesti
1,622 Points

and you mispelled in "integer"...it's not interger

Neil Docherty
Neil Docherty
10,418 Points

The spelling of the variable is consistent and would therefore have no impact on the code.

Jeremy could have just as easily called it "int" or "Z"; both of which are also an incorrect spelling of "integer". As long as it's clear what the variable describes then it's all good.

Jeremy Barbe
Jeremy Barbe
8,728 Points

im dumb and tired....thank you....i need to use the console more