wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS Loops and Functions

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

What is a function in JavaScript?

a)

A function in JavaScript is a type of variable.

b)

A function in JavaScript is a method for creating objects.

c)

A function in JavaScript is a data structure that holds values.

d)

A function in JavaScript is a reusable block of code that performs a specific task.

2.

How do you call a function in JavaScript?

a)

function call()

b)

call functionName

c)

invoke functionName()

d)

functionName()

3.

A loop that executes for a pre-defined number of times

(a)  

4.

A loop that executes until a condition is met is called

(a)  

5.

for ( var i = 0; i < 50; i++ )


How many times will this loop execute

a)

51 times

b)

49 times

c)

50 times

d)

0 times

6.

Which of the iterations runs 25 times

a)

for ( var i = 2; i < 26; i ++ )

b)

for ( var i = 0; i < 25; i ++ )

c)

for ( var i = -1 ; i > 25 ; i -- )

d)

for ( var i = 0; i <= 25; i --)

7.

Given the following code, what is the final value of x?


var x = 0;

function myXFunction() {

x = x + 10;

}

x = x + 1;

a)

11

b)

0

c)

10

d)

1

8.

What code will result in the above?

a)

alert("Please enter your phone number:")

b)

confirm("Please enter your phone number:")

c)

prompt("Please enter your phone number:")

9.

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()

10.

What is the name of this function?

a)

function

b)

spin()

c)

3 turnLeft();

d)

spin();