General Discussion

Nancy Chen
Nancy Chen
1,483 Points

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

Peter Vann
MOD
Peter Vann
Treehouse Moderator 35,363 Points

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.

Nancy Chen
Nancy Chen
1,483 Points

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.

Peter Vann
MOD
Peter Vann
Treehouse Moderator 35,363 Points

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

So:

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

Will log 2