Learn JavaScript from Scratch JavaScript for Everyone - Random Numbers

Learn JavaScript from Scratch JavaScript for Everyone - Random Numbers

Assessment

Interactive Video

Computers

9th - 10th Grade

Hard

Created by

Quizizz Content

FREE Resource

The video tutorial explains how to generate random numbers using JavaScript's Math.random function. It covers generating numbers between 0 and 1, extending this to a range between 0 and 100, and using Math.floor to round numbers to the nearest whole number. The tutorial also demonstrates creating random numbers within a custom range, such as 0 to 83, and emphasizes the importance of these techniques for a final project.

Read more

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What does the Math.random function return?

A number between 0 and 1

A number between 0 and 100

A number between 1 and 100

A number between 0 and 10

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you generate a random number between 0 and 100 using Math.random?

By adding 100 to Math.random

By multiplying Math.random by 100

By subtracting 100 from Math.random

By dividing Math.random by 100

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of using Math.floor with Math.random?

To generate a number between 1 and 100

To generate a number between 0 and 1

To round the number up to the nearest whole number

To round the number down to the nearest whole number

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you generate a random number between 0 and 83?

By multiplying Math.random by 83

By adding 83 to Math.random

By dividing Math.random by 83

By subtracting 83 from Math.random

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the difference between Math.floor and Math.ceil?

Both round to the nearest decimal

Math.floor rounds down, Math.ceil rounds up

Math.floor rounds up, Math.ceil rounds down

Both round to the nearest whole number