Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Variables and Conditionals review

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is a word we set that contains a specific type of data that we use to keep track of information in our code

a)

Variable

b)

Conditional

c)

Object

d)

Method

2.

The information that’s stored inside a variable, such as a number or a name, is called what?

a)

Variable

b)

Value

c)

Object

d)

Conditional

3.

Which word is the variable name in this line of code: var steps = 2;

a)

var

b)

steps

c)

2

d)

;

4.

What word is the variable name in this line of code: var enemy = hero.findNearestEnemy();

a)

findNearestEnemy

b)

hero

c)

enemy

d)

var

5.

What word is the variable name in this line of code: var friend = "George";

a)

"George"

b)

var

c)

=

d)

friend

6.

What is the value in this line of code? var steps = 3;

a)

var

b)

steps

c)

3

d)

;

7.

What is the value in this line of code: var friend = "George";

a)

friend

b)

var

c)

"George"

d)

;

8.

What is a tool that checks conditions to help us plan ahead and make decisions in our code?

a)

Variable

b)

Conditional

c)

Object

d)

Argument

9.

Which line of code will find the nearest friend and save their name as the variable "friend" (must be written correctly)

a)

var friend = hero.findNearestFriend();

b)

var enemy = hero.findNearestEnemy();

c)

hero.findNearestFriend();

d)

var ally = findNearestFriend();

10.

An if statement is also called a what?

a)

Object

b)

Method

c)

Variable

d)

Conditional

11.

What is this an example of: var enemy = "Joker";

a)

Variable

b)

Conditional

c)

Object

d)

Method

12.

How would you reassign this variable to a value of 5: var steps = 2;

a)

var steps = 5

b)

var newStep = 5;

c)

steps = 3;

d)

steps = 5;

13.

What is this an example of?

a)

Value

b)

Method

c)

Variable

d)

Conditional

14.

When writing an else conditional, what does the word "else" replace?

a)

the action

b)

the second if statement

c)

all of the if statements

d)

the numbers

15.

When will the code do the action in under "else"

a)

When distance > 3 is true

b)

When distance > 3 is false

c)

When distance = 5

16.

If the enemy is 4 steps away, what will the hero do?

a)

cast earth wave

b)

cast earth pit on the nearest enemy

c)

cast illusion mist on the nearest enemy

d)

move right

17.

What will the hero do if pathFree === true

a)

move right then up

b)

move left then up

c)

move up then right

d)

move up then left

18.

If the enemy is 2 steps away, what will the hero do?

a)

cast earth wave

b)

cast earth pit on the nearest enemy

c)

cast illusion mist on the nearest enemy

d)

move right

19.

What is wrong with this conditional?

a)

the actions are written incorrectly

b)

there are no parentheses

c)

there are no curly brackets

d)

there are spelling errors

20.

How would you reassign this variable to find the new nearest enemy: var nearestEnemy = hero.findNearestEnemy();

a)

var enemy = hero.findNearestEnemy();

b)

friend = hero.findNearestEnemy();

c)

nearestEnemy = hero.findNearestEnemy();

d)

var nearestEnemy = hero.findNearestEnemy();