wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS If Then Else

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What type of blocks do we use in scratch to create a true false condition

a)

Boolean

b)

Kinetic

c)

Potential

d)

Equilateral

2.

Mia creates a boolean block for

"Moby wearing a hat"

and sets its value to "false."

Which picture matches her boolean block?

a)
b)
c)
d)
3.

How many values does a Boolean variable have?

a)

4

b)

3

c)

2

d)

1

e)

Infinite

4.

The "If" Statement is an example of a _________________

a)

Correctional Statement

b)

Competitive Statement

c)

Conditional Statement

d)

Inquisitive Statement

5.

If it is sunny and windy

It is a good day to go on a picnic!

Else if it is rainy and cold

It is a good day to stay inside!

Else

It is a good day to drink hot chocolate!


If I drank hot chocolate, then what happened?

a)

It was sunny and windy

b)

It was rainy and cold

c)

Neither sunny, windy, rainy, or cold

d)

It was sunny and cold

6.
The second part of if, that is executed when the condition is false
a)
if
b)
else
c)
for
d)
input
7.

Pieces of code that only run "under certain conditions":

a)

conditional statements

b)

control flow statments

c)

syntax

d)

variables

8.

Which of these are correct methods to create a function?

a)

function myFunction {

// Some code }

b)

function myFunction[] {

// Some code }

c)

function myFunction() {

// Some code }

d)

function myFunction(x, y, z) {

// Some code }

9.

A reusable block of code that groups together a sequence of statements to perform a specific task.

a)

Function

b)

Identifier

c)

Argument

d)

Blocks

10.

What is the syntax for creating a function in JavaScript named as Geekfunc?

a)

A) function = Geekfunc()

b)

B) function Geekfunc()

c)

C) function := Geekfunc()

d)

D) function : Geekfunc()

11.

Which of the following is NOT a valid component of a function declaration?

a)

Function keyword

b)

Function name

c)

Pair of Square Braces

d)

Pair of Curly Braces

12.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();

13.

Which one of the following symbols is used for JavaScript comments? / Lequel des symboles suivants est utilisé pour les commentaires JavaScript?

a)

\\

b)

^

c)

?

d)

//

14.
What type of variable is
var typeOfApples="Fuji";
a)
Int
b)
Float
c)
Boolean
d)
String
15.
What type of variable is
var numApples = 2; 
a)
Int
b)
Float
c)
Boolean
d)
String