wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Basics Quiz

Total questions: 9

Worksheet time: 5mins

Name
Class
Date
1.

Which method is used to display data in the console?

a)

log.console()

b)

console.log()

c)

console.display()

d)

log()

2.

How can you create a loop that executes five times?

a)

for (let i = 1; i <= 5; i++) {}

b)

for (i = 0; i < 5; i + 1) {}

c)

foreach (let i in 5) {}

d)

while (i < 5) { i++; }

3.

What does Math.random() do?

a)

Generates a random integer

b)

Generates a random boolean

c)

Generates a random decimal number between 0 and 1

d)

Generates a random string

4.

What is the output of typeof NaN?

a)

"number"

b)

"undefined"

c)

"NaN"

d)

"null"

5.

What will the following code output: console.log(12 % 5)?

a)

2

b)

7

c)

5

d)

0

6.

How do you declare a constant variable in ?

a)

const myVar;

b)

let myVar;

c)

var myVar;

d)

const myVar = value;

7.

What is the result of the expression: 5 + '5'?

a)

10

b)

55

c)

TypeError

d)

5

8.

Which keyword is used to define a function in ?

a)

func

b)

define

c)

function

d)

method

9.

What will the following code output: console.log(5 == '5')?

a)

true

b)

false

c)

TypeError

d)

Undefined