wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS Lesson 31-72

Total questions: 40

Worksheet time: 1hrs 20mins

Name
Class
Date
1.

What is the main difference between let and const in JavaScript?

a)

let is block-scoped, const is not.

b)

const is block-scoped, let is not.

c)

let can be reassigned, const cannot.

d)

const can be reassigned, let cannot.

2.

What is the common convention for declaring an iterator variable in a for loop?

a)

Use the variable name 'loop'

b)

Use the variable name 'index'

c)

Use the variable name 'i'

d)

Use the variable name 'count'

3.

What happens if you try to use a const variable without initializing it?

a)

It will be set to zero.

b)

It will throw an error.

c)

It will be set to null.

d)

It will be set to undefined.

4.

What is the purpose of using a loop in programming?

a)

To declare variables

b)

To perform a task repeatedly

c)

To end a program

d)

To initialize a program

5.

What is a common convention for naming an iterator variable in a loop?

a)

x

b)

j

c)

i

d)

k

6.

What keyword is used to return a value from a function in JavaScript?

a)

break

b)

continue

c)

return

d)

exit

7.

What is considered to be hard-coded in a function?

a)

A value explicitly written in the code

b)

A value passed as an argument

c)

A parameter defined in the function

d)

A variable declared in the global scope

8.

What is the purpose of the return keyword in a function?

a)

To define a value to be returned and stop code execution

b)

To start a loop

c)

To declare a variable

d)

To call another function

9.

How is a function called in programming?

a)

By using a loop

b)

By referencing the function's name and adding ()

c)

By declaring a variable

d)

By using the return keyword

10.

What operator can be used to increase the value of a variable by 1?

a)

Addition operator

b)

Subtraction operator

c)

Increment operator ++

d)

Division operator

11.

What are arguments in the context of functions?

a)

Variables declared inside a function

b)

Values provided to a function call

c)

Functions that return values

d)

Loops within a function

12.

Identify parts of the function. Identify 9

a)

Call statement

b)

Argument

c)

Curly bracket

d)

Body

13.

Identify parts of the function. Identify 2

a)

Call statement

b)

Argument

c)

Name of function

d)

Body

14.

Identify parts of the function. Identify 7

a)

Call statement

b)

Argument

c)

Name of function

d)

Curly bracket- required syntax (rules)

15.

Identify parts of the function. Identify 4

a)

Call statement

b)

Parameters– special variables

c)

Name of function

d)

Curly bracket- required syntax (rules)

16.

Identify parts of the function. Identify 3

a)

Parenthesis – required syntax (rules)

b)

Parameters– special variables

c)

Name of function

d)

Curly bracket- required syntax (rules)

17.

Identify parts of the function. Identify 6

a)

Parenthesis – required syntax (rules)

b)

Parameters– special variables

c)

Body – contains logic statement

d)

Curly bracket- required syntax (rules)

18.

What is a function in JavaScript?

a)

a block of code designed to perform a particular task.

b)

a block of code to be executed, if a specified condition is true

c)

a collection of data items, or elements, that are stored in contiguous memory locations

d)

A series of instructions that are repeated until a condition is met

19.

What is a parameter?

a)

a block of code designed to perform a particular task.

b)

a block of code to be executed, if a specified condition is true

c)

a collection of data items, or elements, that are stored in contiguous memory locations

d)

special variables that are given a value when you call the function, and can be used in your function to dynamically change the result of the function's code

20.

What is an argument?

a)

a block of code designed to perform a particular task.

b)

a value that is passed to a function when it is called

c)

a collection of data items, or elements, that are stored in contiguous memory locations

d)

special variables that are given a value when you call the function, and can be used in your function to dynamically change the result of the function's code

21.

What happens when the condition in the if statement contains the following condition (" ")?

a)

The code block runs

b)

The code block does not run

c)

An error is thrown

d)

The program crashes

22.

What does an else if statement allow you to do?

a)

Declare variables

b)

Check multiple conditions in a single block of code

c)

Create infinite loops

d)

Define functions

23.

If the condition is changed to true, what event will occur?

a)

Declare variables

b)

Check multiple conditions in a single block of code

c)

Create infinite loops

d)

Define functions

24.

What is the output of the code shown?

a)

no output will be shown

b)

true

c)

false

d)

not equal

25.

What is the output of the code shown?

a)

no output will be shown

b)

true

c)

false

d)

not equal

26.

Which of the following are falsy values in JavaScript? Select all that apply

a)

null

b)

NaN

c)

"0"

d)

undefined

27.

What is the output of the code shown?

a)

"Condition is true"

b)

"Condition is false"

c)

Nothing

d)

"Error"

28.

What is the output of the code shown?

a)

Condition is true

b)

Condition is false

c)

It prints nothing

d)

It throws an error

29.

What happens if the first condition in a JavaScript if-else chain is true?

a)

The code block for the if-else condition runs.

b)

The next condition in the chain is checked.

c)

The entire chain stops executing.

d)

The first condition runs.

30.

What is the output of the code shown?

a)

Condition is true

b)

Nothing will output

c)

A switch case.

d)

A function call.

31.

What is NOT a potential risk of an infinite loop in JavaScript?

a)

It will run once and stop.

b)

It can lock up your system.

c)

It will throw an error immediately.

d)

It will automatically fix itself.

32.

What is the general rule for using equality operators in JavaScript?

a)

Always use the equality operator (==).

b)

Always use the strict equality operator (===).

c)

Never use any equality operators.

d)

Use both equality and strict equality operators equally.

33.

Which operator is used to multiply a given value from the current variable value and assign the result back to the variable?

a)

+=

b)

-=

c)

*=

d)

/=

34.

What is the output of the code shown?

a)

4 and 3,2,1,0

b)

3 and 2,1,0

c)

The first element of the array

d)

The last element of the array

35.

What is the output of the code shown?

a)

falsy

b)

truthy

c)

x and y are identical

d)

x and y are not identical

36.

What does the shift() method do in an array?

a)

Adds a value to the end of the array

b)

Removes the last element of the array

c)

Adds a value to the beginning of the array

d)

Removes the first element of the array

37.

What is the result of the following code: const numbers = [2, 1, 3]; numbers.shift();?

a)

[1, 2, 3]

b)

[2, 3]

c)

[3, 1]

d)

[1, 3]

38.

What is the process of removing /* and */ around code to bring it back called?

a)

Commenting

b)

Deleting

c)

Uncommenting

d)

Rewriting

39.

What is the purpose of: /* and */ around code and // in JavaScript?

a)

Commenting

b)

Deleting

c)

Uncommenting

d)

Rewriting

40.

What is the result of the following code: const countTwo = [6,4,2]; countTwo.unshift(8);? What is the length of the code after it is executed.

a)

[8, 6, 4, 2] and length of 4

b)

[3, 2, 1, 0] and length of 2

c)

[8, 2, 4] and length of 3

d)

[4, 8, 2, 6] and length of 1