wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit 4 Wrap-up

Total questions: 20

Worksheet time: 3600secs

Name
Class
Date
1.

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 }

2.

Given the following code, which is considered the parameters of the function


function myFunction(a, b, c) {

var x = a + b + c;

}

a)

x

b)

a

c)

b

d)

c

3.

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

4.

What should go into the indicated location make the final value of x = 11?


var x = 0;

function myXFunction() {

x = x + 10;

}

WRITE CODE HERE

x = x + 1;

a)

function myXFunction()

b)

MYXFUNCTION()

c)

myXFunction()

d)

myxfunction()

5.

Fill in the blanks to allow the following button invoke the myFunction function when clicked

<button id="myButton" (a)   />

function myFunction() {

//Some Code }

6.

Which of the following code will allow the button to invoke hisFunction?


<button id="myButton" value="Click Me" ________ />


function hisFunction(X, Y) {

//Some Code }

a)

onclick = "hisFunction()"

b)

onclick = "hisFunction"

c)

onclick = "hisFunction(1)"

d)

onclick = "hisFunction(1, 2)"

7.

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:")

8.

In which one of these lines of code is A, B and C considered arguments?

a)

function myFunction(A, B, C) { ... }

b)

function myFunction() {

var A; var B; var C; }

c)

myFunction(A, B, C);

d)

var x = function(A, B, C) { ... };

9.

Identify the parameter in the following code:


function First(Second) {

var Third = 0;

}


First(Fourth);

a)

First

b)

Second

c)

Third

d)

Fourth

10.

A JavaScript function is defined with the ______ keyword, followed by a name, followed by parentheses ().

a)

let

b)

function

c)

argument

d)

parameter

11.

Function ______ are listed inside the parentheses () in the function definition.

a)

Parameters

b)

Arguments

c)

Invokes

d)

functions

12.

Function ______ are the values received by the function when it is invoked.

a)

Parameters

b)

Arguments

c)

Invokes

d)

Functions

13.

The code inside the function will execute when "something" ______ (calls) the function:

a)

Parameters

b)

Arguments

c)

Invokes

d)

Functions

14.

If a function in JavaScript is called with missing arguments (less than declared), the missing values are set to ________.

a)

Undefined

b)

Error

c)

NaN

d)

BaNANa

15.

We can assign a _________ to a parameter, in case an argument is not passed to the function.

a)

default value

b)

implicit value

c)

intrinsic value

d)

parametric value

16.

Which line of code has the function being invoked?

a)

1

b)

2

c)

3

d)

4

e)

5

17.

Which line of code includes declaring the parameters of the function?

a)

1

b)

2

c)

3

d)

4

e)

5

18.

What are the arguments of the given function?

a)

x and y

b)

function

c)

multiply

d)

5 and 6

19.

What is the name of the function?

a)

x and y

b)

function

c)

multiply

d)

5 and 6

20.

What are the parameters of the given function?

a)

x and y

b)

function

c)

multiply

d)

5 and 6