Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Bodie Wood
seal-mask
.a{fill-rule:evenodd;}techdegree
Bodie Wood
Full Stack JavaScript Techdegree Student 4,024 Points

Simple Solution

const difference = (low, high) => { return Math.floor(Math.random() * (high - low) + 1) + lower; }

const lowNum = prompt("Please enter a low number"); const highNum = prompt("Please enter a high number");

const userNum = difference(parseInt(lowNum), parseInt(highNum)); alert(${userNum} is between ${lowNum} and ${highNum});

Hi Bodie Wood, what is lower in this line -> (high - low) + 1) + lower; and the last statement is missing back-tick -> alert(${userNum} is between ${lowNum} and ${highNum});

1 Answer

I am not sure what is the question but working with what you have,

const difference = (low, high) => { return Math.floor(Math.random() * (high - low) + 1) + low; }
const lowNum = prompt("Please enter a low number"); 
const highNum = prompt("Please enter a high number");
const userNum = difference(parseInt(lowNum), parseInt(highNum));
alert(`${userNum} is between ${lowNum} and ${highNum}`);

Hope it help!