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

Bartlomiej Pajak
Bartlomiej Pajak
5,063 Points

Here's my solution - looking for some feedback

var number_1 = parseInt(prompt("Write a number"));
var number_2 = parseInt(prompt("Write another number"));
var minNumber = Math.min(number_1, number_2);
var maxNumber = Math.max(number_1, number_2);
var randomNumber = Math.floor(Math.random() * ( maxNumber + 1 - minNumber )) + minNumber;
alert(`Your number between ${minNumber} and ${maxNumber} is ${randomNumber}`);

1 Answer

Steven Parker
Steven Parker
231,172 Points

You didn't provide a link to the course page, so I'm not sure what the objective was. But the code is solid, takes advantage of a template string for output, and allows the limits values to be specified in any order.

I'd say good job! :+1: