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 trialja5on
10,338 PointsJavaScript Numbers..
Really i need help with creating a Integer number. I feel ParseInt should do this but isn't. I know i've gone wrong somewhere at line 8 i think. Although i do think line 11 is right haha.
Thanks for any help guys.
6 Answers
Steven Parker
231,109 PointsHere's some hints:
- Math.random() doesn't require an argument, and any given will be ignored
- Math.random() generates a non-integer value between 0 and 1
- a common way to get random integers is to multiply by a range and then use Math.floor
ja5on
10,338 PointsWhat is an argument and what is a range?
Steven Parker
231,109 PointsAn argument is the data passed to a function, examples:
let dollars = Math.floor(price); // "price" is an argument
let randFloat = Math.random(); // this function doesn't take any argument
And a "range" is a span of numbers (how many numbers). So if you wanted a random integer from 0 to 5, the "range" would be 6 (6 possible numbers: 0,1,2,3,4,5).
ja5on
10,338 PointsThat is very useful! I will print that out, Thank you.
ja5on
10,338 PointsIt's mid August now and i still can't get it. I can't ever seem to remember it all? If its in the exam can i research it online (serious question?)
ja5on
10,338 PointsSo how do i go about getting ready for exam should the time come? (I have it in mind to learn as much as possible first). I haven't seen any information on this, that's why i'm not sure.
Steven Parker
231,109 PointsWhere would you getting this "exam"?
ja5on
10,338 PointsI don't know. I'm finding it hard to get information
Steven Parker
231,109 PointsOnly techdegree students have an "exam", you won't have anything like that. For the rest of us, everything is self-paced and open-book.
If you're going to have an exam somewhere else (employer, certification authority, etc) the source may provide prep tips, or there may be 3rd party prep info providers.