wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript and Game Development Quiz

Total questions: 34

Worksheet time: 19mins

Name
Class
Date
1.

Which of these best defines game mechanics?

a)

Rules that control what players can and cannot do in the game

b)

The game's overall goals or challenges

c)

The objects you use during gameplay

d)

Characters like players and enemies

2.

Which is a good example of game elements?

a)

Characters such as enemies and players

b)

Limits on player actions

c)

The main objective of the game

d)

On-screen indicators like health bars

3.

Which JavaScript command displays text in the console?

a)

print("Text")

b)

console.log("Text")

c)

write("Text")

d)

display("Text")

4.

How can the following code be fixed to print "Greetings!"?

a)

Add quotes around "Greetings!"

b)

Add a dot between "console" and "log"

c)

Replace "consolelog" with "print"

d)

Both add quotes and add dot

5.

What keyword declares a variable in JavaScript?

a)

let

b)

variable

c)

int

d)

x

6.

What does this code output?

a)
  1. This program has no output.

b)
  1. Thanks for taking care of your space!

c)

This program will throw an error.

d)

Time to tidy up!

7.

Which is a correct way to declare and assign a variable?

a)

let amount = 4;

b)

let amount; then amount = 4;

c)

Both are correct

d)

Neither is correct

8.

What function reads text input from the user?

a)

readLine()

b)

readText()

c)

readInt()

d)

console.log()

9.

Which function should you use to get a number from the user?

a)

readInt()

b)

readLine()

c)

readNum()

d)

Both readInt() and readNum()

10.

Which symbol is used for division in JavaScript?

a)

%

b)

/

c)

//

11.

What is the output of this program?

a)

Nothing

b)

22

c)

2+2

d)

4

12.

Why do programmers write functions?

a)

To make code easier to understand

b)

To avoid repeating code

c)

To reuse code multiple times

d)

All of the above

13.

What is the difference between defining and calling a function?

a)

Defining sets what the function does; calling runs the function

b)

Calling sets what the function does; defining runs it

c)

They mean the same thing

d)

Defining calls a function by its name

14.

Where should you place code that creates a character at the start of a game?

a)

At the top of the program outside any function

b)

Inside the setup() function

c)

Inside the draw() function

d)

Any of these places work the same

15.

Where should code that constantly checks for left or right arrow presses go?

a)

At the top outside any function

b)

Inside the setup() function

c)

Inside the draw() function

d)

Inside a custom function called by setup()

16.

How often does the draw() function run by default in JSGameLib?

a)

Once at the start

b)

60 times per second

c)

Once every 60 seconds

d)

Only when manually called

17.

What does this code do when placed at the top of a program?

a)

Assigns a value to human

b)

Declares a variable used outside functions

c)

Declares a variable usable in multiple functions

d)

Declares a function to be defined later

18.

What is a canvas on a webpage?

a)

A photo from an art gallery

b)

A programming language for graphics

c)

A storage for images and multimedia

d)

An area where graphics are drawn and interacted with

19.

Which code creates a JSGameLib canvas 400 pixels wide and 300 tall?

a)

new Canvas(400, 300);

b)

new Canvas(300, 400);

c)

new.Canvas(400, 300);

d)

Canvas.new(300, 400);

20.

Where is the correct place to create a new JSGameLib canvas?

a)

Before all functions

b)

Inside setup()

c)

Inside draw()

d)

After all functions

21.

What does this code do?

a)

Clears webpage and sets background red

b)

Clears canvas border and sets red background

c)

Clears all graphics on canvas and sets background red

d)

Clears variables and sets red background

22.

What is a JSGameLib sprite?

a)

A mythical creature

b)

A graphical object with changeable properties

c)

A variable holding image links only

d)

A variable accessible everywhere in the program

23.

What are sprite properties?

a)

Characteristics like position, size, speed, color

b)

Variables that store sprites

c)

Memory locations where variables are stored

d)

Values saved in variables

24.

Which correctly creates a red circle sprite centered on the canvas?

a)

The code above

b)

Same code but with width and height instead of diameter

c)

Same code but missing quotes around 'red'

d)

Code missing x and y coordinates

25.

Which is NOT a valid boolean value?

a)

true

b)

false

c)

yes

d)

All are valid

26.

The user is clicking a sprite named coin. What does this print?

a)

true

b)

false

c)

pressing

d)

coin.mouse.pressing()

27.

Which becomes true only at the moment the "up" key is pressed?

a)

kb.pressing('up')

b)

kb.presses('up')

c)

mouse.presses('up')

d)

pressing('up')

28.

What kind of statement runs code only if a condition is true?

a)

if statement

b)

Boolean statement

c)

else statement

d)

question statement

29.

What kind of statement runs one block if true and another if false?

a)

if statement

b)

Boolean statement

c)

if/else statement

d)

question statement

30.

What is gameplay?

a)

Instructions on how to play

b)

The overall player experience

c)

The rules of the game

d)

The pieces or objects used

31.

What are game components?

a)

Instructions on playing

b)

Player’s experience

c)

The rules

d)

The pieces or objects used

32.

What is the output of the following JavaScript code segment?

a)

5hello

b)

5 + hello

c)

error on num + str: type mismatch

d)

result

33.
Believe it or not, your calculator is a computer.  You (the user) type in a series of numbers and commands (+, -, =), the calculator processes that data, and the correct answer is displayed on the screen.
The answer that is displayed on your calculator is an example of...
a)
output
b)
input
c)
arguments
d)
binary code
34.

What is printed to the screen if the user enters ‘5’ when the following program is run?

a)

5

b)

25

c)

30

d)

50