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

adding as if a string and not an equation

so this is my code, and I'm getting both answers ok, but in var realNumber I'm getting the userNumber1 and usernumber two smooshed together and not a number between the two. Why did I make the computer Gods angry?

var userNumber1 = prompt("What is the low number?");

var userNumber2 = prompt("What is the high number");

parseInt(userNumber1);

parseInt(userNumber2);

var realNumber = Math.floor(Math.random() * (userNumber2 - userNumber1)) + userNumber1 ;

var message = "<p>" + " You rolled a " + realNumber + "</p>";

document.write(message);

1 Answer

Logan R
Logan R
22,989 Points

Hi!

You forgot to assign the parseInt back into a variable.

var userNumber1 = parseInt(userNumber1);

Hope this helps!