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 trialT. Gontarek
7,030 PointsRandom Number Challenge Part II- My Solution
// Collect input from a user
let userLow = prompt("Enter a low number into the text box bellow.");
let userHigh = prompt("Enter a high number into the text box bellow.");
// Convert the input (as a string) to a number
userLow = parseInt(userLow);
userHigh = parseInt(userHigh);
//conditional if user enters both required numbers
if (userHigh && userLow){
const randomNumber = Math.floor(Math.random(userLow)* userHigh)+1;
console.log(`The random number generated from ${userLow} to ${userHigh} is ${randomNumber}.`)
//if user does not enter required numbers
} else {
console.log('Number is needed to calculate. Reload page and try again.');
}
kevin hudson
Courses Plus Student 11,987 PointsT. Gontarek I tested your solution and if you do low number 2 and high number 4 you can get a 1 as a result.
boi
14,242 PointsThis solution needs a solution.
1 Answer
T. Gontarek
7,030 PointsOOPS! I know I spelled below incorrectly.
Michael Carreon
6,208 PointsMichael Carreon
6,208 PointsNice. This helps!