wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JavaScript Variables Quiz

Total questions: 19

Worksheet time: 10mins

Name
Class
Date
1.

What are variables in JavaScript similar to?

a)

Puzzle pieces

b)

Functions

c)

Little boxes to store values

d)

Strings

e)

Loops

2.

Which keyword is commonly used to declare a variable in JavaScript?

a)

const

b)

let

c)

int

d)

float

e)

var

3.

If you declare a variable without initializing it, what is it called?

a)

Uninitialized

b)

Null

c)

Empty

d)

Undefined

e)

Zeroed

4.

What does initializing a variable mean?

a)

Naming it

b)

Assigning a value to it

c)

Creating a box for it

d)

Naming and assigning a value to it

e)

Deleting it

5.

Which of the following is the correct way to declare and initialize a variable to store the number 10?

a)

int number = 10;

b)

number = 10;

c)

var number = 10;

d)

float number = 10;

e)

number 10;

6.

What is the output of the following code? `var value = 53; value = 75; console.log(value);`

a)

53

b)

75

c)

5375

d)

Error

e)

None of the above

7.

Which type of variable is used to hold true or false values?

a)

String

b)

Integer

c)

Char

d)

Float

e)

Boolean

8.

Which variable declaration contains a decimal point and can hold numbers like 2.5?

a)

Integer

b)

Char

c)

String

d)

Float

e)

Boolean

9.

How are strings represented in JavaScript?

a)

like this "Alice"

b)

Without quotes

c)

Using special characters

d)

Using numbers

e)

All of the above

10.

What type of value does the following variable hold? `var apple = "fruit";`

a)

Integer

b)

Float

c)

Boolean

d)

String

e)

Char

11.

What is the naming convention where each word after the first begins with a capital letter?

a)

SnakeCase

b)

camelCase

c)

PascalCase

d)

kebab-case

e)

UPPER_CASE

12.

Which of the following is a good variable name?

a)

5$age

b)

4_name

c)

var

d)

appleTree

e)

2apples

13.

What type of variable is `var loggedIn = true;`?

a)

Integer

b)

String

c)

Float

d)

Boolean

e)

Char

14.

What is an Integer?

a)

A number with decimal points 小数

b)

A sequence of characters 字符

c)

A true or false value 布尔值

d)

A whole number 整数

e)

A data storage structure储存结构

15.

What is the difference between declaring and initializing a variable?

a)

Declaring means giving it a name and initializing means assigning it a value.

b)

Declaring means deleting it and initializing means recreating it.

c)

Declaring and Initializing mean the same thing.

d)

Declaring means assigning it a value and initializing means deleting it.

e)

None of the above

16.

Which of these is a special keyword in JavaScript?

a)

variable

b)

init

c)

string

d)

true

e)

function

17.

Which of the following is NOT a valid way to declare and initialize a variable in JavaScript?

a)

var name = "John";

b)

int age = 25;

c)

var loggedIn = true;

d)

var price = 10.5;

e)

var _privateVar = "hidden";

18.

In the context of JavaScript, what is a Float?

a)

A sequence of characters

b)

A true or false value

c)

A whole number

d)

A numeric value with decimal precision

e)

A data storage type

19.

If you want a calculation result to be a decimal, what must one of your numbers be?

a)

Integer

b)

Char

c)

String

d)

Boolean

e)

Float