wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Javascript Quiz 1

Total questions: 9

Worksheet time: 9mins

Name
Class
Date
1.

What range of numbers will the following print out?


console.log( Math.floor(Math.random() * 20) );

a)

0 to 20

b)

0.0 to 19.999999999

c)

0 to 19

d)

0.0 to 20.0

e)

1 to 21

2.

What range of numbers will the following print out?


console.log( Math.floor(Math.random() * 10) + 3 );

a)

0 to 10

b)

0.0 to 9.999999999

c)

3 to 12

d)

3.0 to 13.0

e)

3 to 13

3.

What will the following if statement print?


let x = 10;

if( x > 12 ) {

console.log("Pog");

}

else {

console.log("Squid");

}

a)

Pog

b)

Squid

c)

Pog Squid

d)

It will cause an error.

4.

What will the following print out?


let age = 26;

if(age > 25) {

console.log("Hello");

}

if(age > 40) {

console.log("Boomer");

}

else {

console.log("Youngster");

}

}

a)

Hello

Boomer

b)

Hello

c)

Boomer

d)

Youngster

e)

Hello

Youngster

5.

What will the following print out?


console.log(30 == "30");

a)

true

b)

false

c)

pog

d)

It will cause an error.

e)

uh...

6.

choice = "2";

if(choice === 2) {

alert("Leet");

}

else {

console.log("Haxxor");

}

a)

Leet

Haxxor

b)

Leet

c)

Haxxor

d)

Neither prints out but no error occurs.

e)

An error occurs.

7.

What does the following print out?

let x = -25;

let y = 100;

if(Math.abs(x) > 0) {

console.log(x);

}

else if (y < 99) {

console.log(y);

}

a)

-25

b)

25

c)

Nothing will be printed but it won't cause an error.

d)

100

e)

It will cause an error.

8.

let score = 5;

if(score > 1) {

console.log("GG");

}

if(score < 10) {

console.log(" noob");

}

else {

console.log(" gamer");

}

a)

noob

b)

GG

gamer

c)

GG

d)

GG

noob

e)

gamer

9.

function myFun(stuff) {

console.log("stuff " + stuff);

}

myFun("a");

a)

a

b)

stuff a

c)

stuff stuff

d)

It will cause an error.

e)

stuff