Font size
WorksheetsJS Lesson 31-72
Total questions: 40
Worksheet time: 1hrs 20mins
What is the main difference between let and const in JavaScript?
let is block-scoped, const is not.
const is block-scoped, let is not.
let can be reassigned, const cannot.
const can be reassigned, let cannot.
What is the common convention for declaring an iterator variable in a for loop?
Use the variable name 'loop'
Use the variable name 'index'
Use the variable name 'i'
Use the variable name 'count'
What happens if you try to use a const variable without initializing it?
It will be set to zero.
It will throw an error.
It will be set to null.
It will be set to undefined.
What is the purpose of using a loop in programming?
To declare variables
To perform a task repeatedly
To end a program
To initialize a program
What is a common convention for naming an iterator variable in a loop?
x
j
i
k
What keyword is used to return a value from a function in JavaScript?
break
continue
return
exit
What is considered to be hard-coded in a function?
A value explicitly written in the code
A value passed as an argument
A parameter defined in the function
A variable declared in the global scope
What is the purpose of the return keyword in a function?
To define a value to be returned and stop code execution
To start a loop
To declare a variable
To call another function
How is a function called in programming?
By using a loop
By referencing the function's name and adding ()
By declaring a variable
By using the return keyword
What operator can be used to increase the value of a variable by 1?
Addition operator
Subtraction operator
Increment operator ++
Division operator
What are arguments in the context of functions?
Variables declared inside a function
Values provided to a function call
Functions that return values
Loops within a function
Identify parts of the function. Identify 9
Call statement
Argument
Curly bracket
Body
Identify parts of the function. Identify 2
Call statement
Argument
Name of function
Body
Identify parts of the function. Identify 7
Call statement
Argument
Name of function
Curly bracket- required syntax (rules)
Identify parts of the function. Identify 4
Call statement
Parameters– special variables
Name of function
Curly bracket- required syntax (rules)
Identify parts of the function. Identify 3
Parenthesis – required syntax (rules)
Parameters– special variables
Name of function
Curly bracket- required syntax (rules)
Identify parts of the function. Identify 6
Parenthesis – required syntax (rules)
Parameters– special variables
Body – contains logic statement
Curly bracket- required syntax (rules)
What is a function in JavaScript?
a block of code designed to perform a particular task.
a block of code to be executed, if a specified condition is true
a collection of data items, or elements, that are stored in contiguous memory locations
A series of instructions that are repeated until a condition is met
What is a parameter?
a block of code designed to perform a particular task.
a block of code to be executed, if a specified condition is true
a collection of data items, or elements, that are stored in contiguous memory locations
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
What is an argument?
a block of code designed to perform a particular task.
a value that is passed to a function when it is called
a collection of data items, or elements, that are stored in contiguous memory locations
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
What happens when the condition in the if statement contains the following condition (" ")?
The code block runs
The code block does not run
An error is thrown
The program crashes
What does an else if statement allow you to do?
Declare variables
Check multiple conditions in a single block of code
Create infinite loops
Define functions
If the condition is changed to true, what event will occur?
Declare variables
Check multiple conditions in a single block of code
Create infinite loops
Define functions
What is the output of the code shown?
no output will be shown
true
false
not equal
What is the output of the code shown?
no output will be shown
true
false
not equal
Which of the following are falsy values in JavaScript? Select all that apply
null
NaN
"0"
undefined
What is the output of the code shown?
"Condition is true"
"Condition is false"
Nothing
"Error"
What is the output of the code shown?
Condition is true
Condition is false
It prints nothing
It throws an error
What happens if the first condition in a JavaScript if-else chain is true?
The code block for the if-else condition runs.
The next condition in the chain is checked.
The entire chain stops executing.
The first condition runs.
What is the output of the code shown?
Condition is true
Nothing will output
A switch case.
A function call.
What is NOT a potential risk of an infinite loop in JavaScript?
It will run once and stop.
It can lock up your system.
It will throw an error immediately.
It will automatically fix itself.
What is the general rule for using equality operators in JavaScript?
Always use the equality operator (==).
Always use the strict equality operator (===).
Never use any equality operators.
Use both equality and strict equality operators equally.
Which operator is used to multiply a given value from the current variable value and assign the result back to the variable?
+=
-=
*=
/=
What is the output of the code shown?
4 and 3,2,1,0
3 and 2,1,0
The first element of the array
The last element of the array
What is the output of the code shown?
falsy
truthy
x and y are identical
x and y are not identical
What does the shift() method do in an array?
Adds a value to the end of the array
Removes the last element of the array
Adds a value to the beginning of the array
Removes the first element of the array
What is the result of the following code: const numbers = [2, 1, 3]; numbers.shift();?
[1, 2, 3]
[2, 3]
[3, 1]
[1, 3]
What is the process of removing /* and */ around code to bring it back called?
Commenting
Deleting
Uncommenting
Rewriting
What is the purpose of: /* and */ around code and // in JavaScript?
Commenting
Deleting
Uncommenting
Rewriting
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.
[8, 6, 4, 2] and length of 4
[3, 2, 1, 0] and length of 2
[8, 2, 4] and length of 3
[4, 8, 2, 6] and length of 1
