Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JavaScript Variables Quiz

Total questions: 26

Worksheet time: 22mins

Name
Class
Date
1.

Show Me What You Got! How do you declare a variable in JavaScript?

a)

let

b)

function

c)

var

d)

variable

2.

Show Me What You Got! What are the different types of values that a variable in JavaScript can represent?

a)

apple, banana, orange, grape

b)

cat, dog, bird, fish

c)

red, blue, green, yellow

d)

string, number, boolean, object, function, undefined

3.

Show Me What You Got! Is JavaScript attentive to the way we dress up variable names, paying attention to uppercase and lowercase letters?

a)

No

b)

Yes

c)

Sometimes

d)

Only on weekends

4.

Show Me What You Got! You're creating a new variable in JavaScript for your intergalactic DJ app. What rules must you follow for naming it?

a)

Variable names must begin with a letter, underscore (_), or dollar sign ($)

b)

Variable names must begin with a special character

c)

Variable names must begin with a number

d)

Variable names must begin with a hyphen

5.

Show Me What You Got! Imagine you're a developer working on a JavaScript project. You declare a variable but forget to assign it any value. What does JavaScript default this variable to?

a)

undefined

b)

false

c)

0

d)

null

6.

Show Me What You Got! Explain the difference between 'let', 'var', and 'const' in JavaScript variable declaration.

a)

They are all used for declaring global variables only

b)

They have different scopes and usage in JavaScript.

c)

They are all the same and can be used interchangeably

d)

They are all outdated and not recommended for modern JavaScript development

7.

Show Me What You Got! Can a variable name in JavaScript be initiated with a digit?

a)

Yes

b)

Maybe

c)

Only on Tuesdays

d)

No

8.

Show Me What You Got! Why do we use camelCase or snake_case when naming variables in JavaScript?

a)

To add unnecessary complexity to the code

b)

To make variable names more readable and understandable.

c)

To make the code run faster

d)

To confuse other programmers

9.

Show Me What You Got! Imagine you're coding a new feature in JavaScript and you declare a variable using 'let' inside a for-loop. What's the scope of this variable?

a)

Global scope

b)

Function scope

c)

Class scope

d)

Block scope

10.
Which of the following answer choices is NOT an example of a variable?
a)
8
b)
x
c)
u
d)
n
11.

What is the variable in 3x - 5

a)

x

b)

5

c)

3

12.

What are the variables in 3x + y

a)

3x

b)

x,y

c)

x

d)

y

13.
What does the word in red symbolize: hero.moveRight();?
a)
The function
b)
The method
c)
The last part
d)
The end of the code
14.
It is not important to capitalize the name of the variables.
a)
True
b)
False
15.
JavaScript comments starts with what? 
a)
" "
b)
()
c)
//
d)
;
16.
Why do we use comments? 
a)
To leave hints
b)
To leave cool messages
c)
To give answers
d)
To communicate
17.

True or False: _Mondaylunch

is proper naming convention

a)

True

b)

False

18.

True or False: Var good Day;

is a proper naming for variables

a)

True

b)

False

19.

True or False: SummerTime

Is a proper naming convention

a)

True

b)

False

20.

True or False: $today_Scoer

is a proper naming convention

a)

True

b)

False

21.

Number, Boolean, String; are basic what?

a)

Data Types

b)

Data

c)

Variables

d)

Variable data

22.

What keyword do you need to use to define a variable in JavaScript?

a)

X

b)

Variable

c)

int

d)

Var

23.

What is the ID this variable is referencing?

var mainB = document.getElementById("mainButton");

a)

var

b)

document

c)

mainButton

d)

mainB

24.

What is Top Down Design?

a)

Starting with the most specific problems and then working up to solve the big problem

b)

Working from the top of your program and coding down to the bottom

c)

Starting with the biggest problem and then working down to solve the more specific problems

d)

Implementing all of the functions first, then putting them together in the start function

25.
Algorithm
a)
A precise sequence of instructions for processes that can be executed by a computer
b)
To repeat in order to achieve, or get closer to, a desired goal.
c)
Application Program Interface: a collection of commands made available to a programmer
d)
Putting commands in correct order so computers can read the commands.
e)
Repeating actions that have a predetermined beginning, end, and increment (step interval)
26.
Blocks
a)
pieces of code that you use to solve a problem.
b)
a classic method for learning programming with commands to control movement and drawing of an on-screen robot
c)
Putting commands in correct order so computers can read the commands.
d)
A generic term for a type of programming statement (usually an if-statement) that uses a Boolean condition to determine, or select, whether or not to run a certain block of statements.
e)
the optimal time a program takes to run on a computer, the optimal time or number of people required to create, the optimal number of resources required to run, etc