wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Variables/Conditionals

Total questions: 6

Worksheet time: 3mins

Name
Class
Date
1.

What is the value of this variable?


let myVariable;

a)

null

b)

0

c)

undefined

d)

defined

2.

What is the value of this variable?


let someVariable = true;

someVariable = 58;

a)

58

b)

true

c)

error

d)

null

3.

What will happen when this code runs?

const newVariable = ["an", "array", "of", "strings"];

newVariable = "Just a string";

console.log(newVariable);

a)

null

b)

it will print "just a string" to the console

c)

nothing

d)

error

4.

What will print to the console?


let myNumber = 45;


if(myNumber < 20){

console.log("I am less then twenty");

}

a)

nothing

b)

I am less then twenty

c)

error

d)

undefined

5.

What will print to the console?


let myString = "hello";


if (myString === "HELLO"){

console.log("it matches")

} else {

console.log("It does not match")

}

a)

it matches

b)

error

c)

nothing

d)

It does not match

6.

What will print to the console?


const myBoolean = false;


if (myBoolean === true){

myBoolean = "Yellow";

console.log(myBoolean);

} else if (myBoolean === false){

myBoolean = "Blue";

console.log(myBoolean);

} else {

console.log("It didn't work");

}

a)

Yellow

b)

Blue

c)

error

d)

It din't work