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 trialRyan Atkins
8,635 PointsCan't get minimum number to return.
I did the same method you did and, like you, never got the minimum value entered. For instance, if 4 was my minimum number, I'd only be able to return 5 and higher. Why is this?
Ryan Atkins
8,635 PointsAlthough I figured it out, here was what I had done. Rather than having my +1 affecting the number generated by random(), I was adding after the fact. Took a little bit to wrap my head around it.
function getRandom(num1, num2) { alert(num1 + " and " + num2); var ourNum = Math.floor(Math.random() * (num2 - num1) + 1) + num1; return ourNum; }
alert(getRandom(4, 6));
Colin Bell
29,679 PointsColin Bell
29,679 PointsPost the code you are trying to use.