NEW
Font size
WorksheetsJavaScript and Game Development Quiz
Total questions: 34
Worksheet time: 19mins
Which of these best defines game mechanics?
Rules that control what players can and cannot do in the game
The game's overall goals or challenges
The objects you use during gameplay
Characters like players and enemies
Which is a good example of game elements?
Characters such as enemies and players
Limits on player actions
The main objective of the game
On-screen indicators like health bars
Which JavaScript command displays text in the console?
print("Text")
console.log("Text")
write("Text")
display("Text")
How can the following code be fixed to print "Greetings!"?
Add quotes around "Greetings!"
Add a dot between "console" and "log"
Replace "consolelog" with "print"
Both add quotes and add dot
What keyword declares a variable in JavaScript?
let
variable
int
x
What does this code output?
This program has no output.
Thanks for taking care of your space!
This program will throw an error.
Time to tidy up!
Which is a correct way to declare and assign a variable?
let amount = 4;
let amount; then amount = 4;
Both are correct
Neither is correct
What function reads text input from the user?
readLine()
readText()
readInt()
console.log()
Which function should you use to get a number from the user?
readInt()
readLine()
readNum()
Both readInt() and readNum()
Which symbol is used for division in JavaScript?
%
/
//
What is the output of this program?
Nothing
22
2+2
4
Why do programmers write functions?
To make code easier to understand
To avoid repeating code
To reuse code multiple times
All of the above
What is the difference between defining and calling a function?
Defining sets what the function does; calling runs the function
Calling sets what the function does; defining runs it
They mean the same thing
Defining calls a function by its name
Where should you place code that creates a character at the start of a game?
At the top of the program outside any function
Inside the setup() function
Inside the draw() function
Any of these places work the same
Where should code that constantly checks for left or right arrow presses go?
At the top outside any function
Inside the setup() function
Inside the draw() function
Inside a custom function called by setup()
How often does the draw() function run by default in JSGameLib?
Once at the start
60 times per second
Once every 60 seconds
Only when manually called
What does this code do when placed at the top of a program?
Assigns a value to human
Declares a variable used outside functions
Declares a variable usable in multiple functions
Declares a function to be defined later
What is a canvas on a webpage?
A photo from an art gallery
A programming language for graphics
A storage for images and multimedia
An area where graphics are drawn and interacted with
Which code creates a JSGameLib canvas 400 pixels wide and 300 tall?
new Canvas(400, 300);
new Canvas(300, 400);
new.Canvas(400, 300);
Canvas.new(300, 400);
Where is the correct place to create a new JSGameLib canvas?
Before all functions
Inside setup()
Inside draw()
After all functions
What does this code do?
Clears webpage and sets background red
Clears canvas border and sets red background
Clears all graphics on canvas and sets background red
Clears variables and sets red background
What is a JSGameLib sprite?
A mythical creature
A graphical object with changeable properties
A variable holding image links only
A variable accessible everywhere in the program
What are sprite properties?
Characteristics like position, size, speed, color
Variables that store sprites
Memory locations where variables are stored
Values saved in variables
Which correctly creates a red circle sprite centered on the canvas?
The code above
Same code but with width and height instead of diameter
Same code but missing quotes around 'red'
Code missing x and y coordinates
Which is NOT a valid boolean value?
true
false
yes
All are valid
The user is clicking a sprite named coin. What does this print?
true
false
pressing
coin.mouse.pressing()
Which becomes true only at the moment the "up" key is pressed?
kb.pressing('up')
kb.presses('up')
mouse.presses('up')
pressing('up')
What kind of statement runs code only if a condition is true?
if statement
Boolean statement
else statement
question statement
What kind of statement runs one block if true and another if false?
if statement
Boolean statement
if/else statement
question statement
What is gameplay?
Instructions on how to play
The overall player experience
The rules of the game
The pieces or objects used
What are game components?
Instructions on playing
Player’s experience
The rules
The pieces or objects used
What is the output of the following JavaScript code segment?
5hello
5 + hello
error on num + str: type mismatch
result
The answer that is displayed on your calculator is an example of...
What is printed to the screen if the user enters ‘5’ when the following program is run?
5
25
30
50
