wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Quiz 2

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

In coding, a variable is used to:

a)

Store a value in memory

b)

Draw shapes

c)

Store a value that does not change

d)

Display the result of a math equation

2.

What is a list of steps you can follow to finish a task?

a)

Program

b)

Code

c)

Bug

d)

Algorithm

3.

What is an error in a program that prevents a program from running as expected?

a)

Program

b)

Code

c)

Bug

d)

Algorithm

4.

What are statements that are only run if something is true?

a)

Program

b)

Conditionals

c)

Bug

d)

Algorithm

5.

When drawing in JavaScript, the coordinates for the top left of the screen are ___.

a)

(0, 400)

b)

(0, 0)

c)

(400, 0)

d)

(400, 400)

6.

The command: ellipse(200,100, 20, 20) will draw:

a)

a rectangle whose center is is at (200,100) and is 20 pixels wide and 20 pixels tall

b)

a circle whose center is at (20,20) and 200 pixels wide and 100 pixels tall

c)

a circle whose center is at (200, 100) and is 20 pixels wide by 20 pixels tall

d)

a rectangle whose center is at (20, 20) and is 200 pixels wide by 100 pixels tall

7.

The code below will:

a)

Draw a circle

b)

Draw many circles according to the mouse position

c)

Draw many circles diagonally across the screen

d)

Draw many circles in the center of the screen

8.

The code background(rgb(100,0,0)) will color the background in:

a)

red

b)

green

c)

blue

d)

black

9.

After running the code to the right, what will be displayed?

a)

x

b)

3

c)

15

d)

Nothing will be displayed

10.

Which of the following represents a comment in JavaScript?

a)

<!---------->

b)

//

c)

/

d)

#

11.

A condition is ___.

a)

any expression that evaluates to True or False.

b)

a built-in function that assigns a Boolean value to a variable.

c)

a formula executed for a result.

d)

an operand that indicates both conditions are True or False.

12.

Which variable is named incorrectly?

a)

4sides

b)

sides_four

c)

sides4

d)

sidesFour

13.

In which direction will the sprite move?

plane.x = plane.x + 2

a)

left

b)

right

c)

up

d)

down

14.

In which direction will the sprite move?

bee.y = bee.y - 2

a)

left

b)

right

c)

up

d)

down

15.

Which sprite property would you change to make the sprite grow in size?

a)

sprite.x

b)

sprite.y

c)

sprite.scale

d)

sprite.rotation

16.

Which sprite property would you change to make the sprite turn in a circle?

a)

sprite.x

b)

sprite.y

c)

sprite.scale

d)

sprite.rotation

17.

When calling sprite.IsTouching(target) and you increase the score, why could the score go up many numbers at once?

a)

Because the draw() function is a loop and the two sprites are touching many times.

b)

The score only goes up once. The sprites only touch once.

c)

The program knows that I don't want to increase the score just by one and gives me a larger number because it thinks it's better to use larger numbers.

d)

Because the sprite doesn't actually touch once the code sprite.visible = false is run.

18.

What's the difference between var sprite, and var x?

a)

With a sprite you will need to call createSprite()

b)

With a sprite you will need to call setAnimation( )

c)

the variable x is only used to hold a value that can be changed.

d)

all of the above.

19.

The code if(keyDown("up")) will have a boolean value of

a)

true if the user presses the down key

b)

false if the user presses the down key

c)

true if the user presses the up key

d)

false if the user presses the up key

20.

In the draw loop, if you call the text function before the drawSprites and/or background function, what happens?

a)

You won't be able to see your text because the sprites and background will be drawn on top of the text.

b)

You will be able to see your text because Game Lab knows you want to see the text.

c)

You won't be able to see your sprites or background because order doesn't matter.

d)

You will be able to see your text because the sprites and the background will be drawn after the text.