Free Practice Quiz Question List

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.

20 questions
01
True or false
1 point

By default, JavaScript statements run from top to bottom unless a function call, condition, or loop changes that flow.

  1. A

    True

  2. B

    False

02
Written response
1 point

What is the JavaScript type of the value true?

03
Choose all
1 point

Select all statements that accurately describe JavaScript values or types.

  1. A

    null can represent an intentional absence of a value.

  2. B

    undefined often indicates that a value has not been assigned.

  3. C

    Arrays and objects can group values.

  4. D

    true is a string.

  5. E

    42 is a boolean.

04
Choose one
1 point

A page tracks a visit count that starts at 0 and is reassigned after each visit. Which declaration is appropriate for the count binding?

  1. A

    const

  2. B

    let

  3. C

    return

  4. D

    if

05
Fill in the blank
1 point

Complete each statement with the correct function term.

In function makeGreeting(name), name is the . In makeGreeting("Ari"), "Ari" is the .

06
True or false
1 point

In JavaScript, the same variable can hold values of different types at different times.

  1. A

    True

  2. B

    False

07
True or false
1 point

A while loop repeats as long as its condition remains true.

  1. A

    True

  2. B

    False

08
Written response
1 point

What number is returned by this function call?

09
Choose one
1 point

What is the final line printed by this loop?

  1. A

    Step 1

  2. B

    Step 2

  3. C

    Step 3

  4. D

    Step 4

10
Choose all
1 point

Select all statements that accurately describe JavaScript functions.

  1. A

    A parameter is named in a function definition.

  2. B

    An argument is supplied in a function call.

  3. C

    return sends a value back and ends that function call.

  4. D

    A function with no return value produces null.

  5. E

    Functions cannot be callable values.

11
Choose one
1 point

What is the result of this JavaScript expression?

  1. A

    true

  2. B

    false

  3. C

    7

  4. D

    "7"

12
Fill in the blank
1 point

Complete the statement: A return statement sends a value back and that function call.

13
Open ended
1 point

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.

14
Choose one
1 point

A page stores a user’s theme preference like this:

What happens when this code runs?

  1. A

    The code fails because every property of a const object is immutable.

  2. B

    The code runs and logs "dark" because the object’s property can be changed.

  3. C

    The code runs and logs "light" because const prevents the property change.

  4. D

    The code fails because an object declared with const cannot be accessed through dot notation.

15
Choose one
1 point

A developer writes:

What happens when the final line runs?

  1. A

    It logs "Saved" because let variables are available throughout the function.

  2. B

    It logs undefined because the block-scoped variable is reset after the block.

  3. C

    It throws an error because status is not available outside its block.

  4. D

    It logs "Saved" because a variable declared inside an if statement becomes global.

16
Choose one
1 point

A form handler uses this code when the submitted name is empty:

Which message does it log?

  1. A

    It logs "Please enter your name."

  2. B

    It logs "Hello, !"

  3. C

    It logs both messages, in order.

  4. D

    It does not log anything because an empty string stops the program.

17
Choose one
1 point

A developer wants this loop to run for steps 3, 2, and 1, then stop. Which change makes it do that?

  1. A

    Replace the condition with step <= 1.

  2. B

    Replace the initialization with let step = 1 and keep step++.

  3. C

    Replace the condition with step !== 1.

  4. D

    Replace step++ with step--.

18
Choose one
1 point

A function receives an array of labels and loops through it like this:

What does item represent during each iteration?

  1. A

    The index of the current element, starting at zero.

  2. B

    The current element from the array.

  3. C

    The entire array on every iteration.

  4. D

    The number of elements remaining in the array.

19
Written response
1 point

What exact text is logged by this code?

Enter the exact console output, including punctuation.

20
Written response
1 point

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.