wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Mastering JavaScript Variables and Conditions

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What keyword is used to declare a variable in JavaScript?

a)

define

b)

assign

c)

var, let, const

d)

initialize

2.

Which of the following is NOT a data type in JavaScript: String, Number, Character, Boolean?

a)

Array

b)

Character

c)

Decimal

d)

Text

3.

What will the following code output: console.log(typeof 42);?

a)

string

b)

number

c)

boolean

d)

undefined

4.

How do you declare a constant variable in JavaScript?

a)

const variableName = value;

b)

let variableName = value;

c)

var variableName = value;

d)

constant variableName = value;

5.

What is the result of the expression true && false?

a)

undefined

b)

true

c)

false

d)

null

6.

Which statement is used to execute a block of code if a specified condition is true?

a)

when statement

b)

if statement

c)

loop statement

d)

case statement

7.

What is the output of the following code: console.log(5 == '5');?

a)

undefined

b)

false

c)

NaN

d)

true

8.

Which operator is used to check for both value and type equality in JavaScript?

a)

<=

b)

!==

c)

===

d)

==

9.

What will the following code return: console.log(3 > 2 && 2 < 1);?

a)

null

b)

true

c)

false

d)

undefined

10.

How do you write an if statement that checks if a variable 'x' is greater than 10?

a)

if (x > 10) { ... }

b)

if (x >= 10) { ... }

c)

if (x == 10) { ... }

d)

if (x < 10) { ... }