By default, JavaScript statements run from top to bottom unless a function call, condition, or loop changes that flow.
5 JavaScript Fundamentals Online Quiz Questions
Use this free practice quiz with 20 questions to review 5 JavaScript Fundamentals, test your knowledge, and prepare for your next test or exam.
What is the JavaScript type of the value true?
Select all statements that accurately describe JavaScript values or types.
- A
nullcan represent an intentional absence of a value. - B
undefinedoften indicates that a value has not been assigned. - C
Arrays and objects can group values.
- D
trueis a string. - E
42is a boolean.
A page tracks a visit count that starts at 0 and is reassigned after each visit. Which declaration is appropriate for the count binding?
- A
const - B
let - C
return - D
if
Complete each statement with the correct function term.
In function makeGreeting(name), name is the . In makeGreeting("Ari"), "Ari" is the .
In JavaScript, the same variable can hold values of different types at different times.
- A
True
- B
False
A while loop repeats as long as its condition remains true.
- A
True
- B
False
What number is returned by this function call?
What is the final line printed by this loop?
- A
Step 1 - B
Step 2 - C
Step 3 - D
Step 4
Select all statements that accurately describe JavaScript functions.
- A
A parameter is named in a function definition.
- B
An argument is supplied in a function call.
- C
returnsends a value back and ends that function call. - D
A function with no return value produces
null. - E
Functions cannot be callable values.
What is the result of this JavaScript expression?
- A
true - B
false - C
7 - D
"7"
Complete the statement: A return statement sends a value back and that function call.
A page interaction should greet a visitor when their entered name is non-empty, ask for a name otherwise, and then display a step message a fixed number of times. Describe how you would use JavaScript control flow to implement both the choice and the repetition.
A page stores a user’s theme preference like this:
What happens when this code runs?
- A
The code fails because every property of a const object is immutable.
- B
The code runs and logs "dark" because the object’s property can be changed.
- C
The code runs and logs "light" because const prevents the property change.
- D
The code fails because an object declared with const cannot be accessed through dot notation.
A developer writes:
What happens when the final line runs?
- A
It logs "Saved" because let variables are available throughout the function.
- B
It logs undefined because the block-scoped variable is reset after the block.
- C
It throws an error because status is not available outside its block.
- D
It logs "Saved" because a variable declared inside an if statement becomes global.
A form handler uses this code when the submitted name is empty:
Which message does it log?
- A
It logs "Please enter your name."
- B
It logs "Hello, !"
- C
It logs both messages, in order.
- D
It does not log anything because an empty string stops the program.
A developer wants this loop to run for steps 3, 2, and 1, then stop. Which change makes it do that?
- A
Replace the condition with
step <= 1. - B
Replace the initialization with
let step = 1and keepstep++. - C
Replace the condition with
step !== 1. - D
Replace
step++withstep--.
A function receives an array of labels and loops through it like this:
What does item represent during each iteration?
- A
The index of the current element, starting at zero.
- B
The current element from the array.
- C
The entire array on every iteration.
- D
The number of elements remaining in the array.
What exact text is logged by this code?
Enter the exact console output, including punctuation.
This loop should count down from 3 to 1, but its update moves in the wrong direction. What JavaScript update expression should replace step++ so the loop eventually stops?
Enter the JavaScript update expression only.