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

General Discussion

Am I missing some videos for the TSJS starter pack?

I don't know where else to ask this, but I'm doing the TSJS starter right now for an apprenticeship. I'm at the part where I finished everything and am doing the practices.

It's going over parameters, functions, and random numbers and arrays, which were not things that were included in my starter videos. Am I missing something? I am feeling very overwhelmed and need to get this done because this is time-sensitive, but I literally have never seen any of these videos. I have to finish the TalentPath starter project but can't do it because I don't know how to create a random number.

2 Answers

Is this JS?

Math.floor(Math.random()*10)

will give you a random integer from 0 to 9. (+1 will make it 1 to 10) Math.random produces a random number from 0 to 1 (such as 0.7734582910345555). *10 would make that number 7.734582910345555. Math.floor rounds down to the nearest integer (crops the decimal part), so to 7 +1 would make it 8.

Didn't know where to put this, maybe I'll change it to General Discussion (unless I can't anymore).

Yes, that one, among some other things that I feel confused about, like Math.ciel (which I will look up tomorrow) and I didn't see any videos going over return either but I figured it out after a search. That is very helpful. I'll watch some other videos to see if that'll help. I'm going to try to post the code that I come up with here tomorrow because I want to get it done.

Math.ceil (for ceiling) rounds UP to the nearest integer.

So:

x = Math.ceil(1.4);
console.log( x );

Will log 2