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 trialBryan Valencia
Full Stack JavaScript Techdegree Student 4,733 PointsMy solution, for critique and to help anyone else who might need it.
Solution to Challenge, just in case, open for scrutiny
I'm sure I could've been more efficient in more than one way and I'd love to get feedback. I used Math.round instead of Math.floor because I thought if you wanted to generate a number that included both numbers in the range, than .floor could never give you the max, and .ceil could never give you the min.
var floorNum = prompt("Input a floor number :)");
var ceilNum = prompt("Input ceiling number :)");
var parseFirstNum = parseInt(floorNum);
var parseSecNum = parseInt(ceilNum);
var randNum = Math.round(Math.random() * (parseSecNum - parseFirstNum) + parseFirstNum);
document.write(randNum);
Colin Marshall
32,861 PointsLooks good! You might also want to add a conditional to check to make sure that the floor number is less than the ceiling number, and you could also put it in a function like Robert Richey's solution.
Robert Richey
Courses Plus Student 16,352 PointsRobert Richey
Courses Plus Student 16,352 PointsHi Bryan,
Looks good! My only feedback is that I'd create a function to generate the random number - abstracting away the logic.
Cheers!