Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
JavaScript lets you create random numbers, which you can use to add variety and surprise in your programs. You generate a random number in JavaScript via a method named Math.random().
Resources
Example Return Values
Math.floor() | Return Value | Math.ceil() | Return Value |
---|---|---|---|
Math.floor() |
Math.ceil() |
||
Math.floor(1.2) |
1 |
Math.ceil(1.2) |
2 |
Math.floor(0.0012) |
0 |
Math.ceil(0.0012) |
1 |
Math.floor(5.028) |
5 |
Math.ceil(5.028) |
6 |
Math.floor(2) |
2 |
Math.ceil(2) |
2 |
Math.floor(0) |
0 |
Math.ceil(0) |
0 |
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Frank Kirok
Full Stack JavaScript Techdegree Student 391 Points1 Answer
-
Max Primo
976 PointsSo I was testing out the Math.ceil and Math.floor. But I never got 0 when I used Math.ceil. Mistake in the video?
Posted by Max PrimoMax Primo
976 Points3 Answers
-
MD MONIRUZZAMAN
6,130 Points2 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up