JavaScript Foundations: Basics and Core Concepts Quiz Quiz

  1. Introduction to JavaScript

    Which of the following statements is true about where JavaScript code can run?

    1. B. Only inside databases
    2. A. Only in document editors
    3. E. Only within spreadsheets
    4. C. Both in web browsers and on servers
    5. D. Only in desktop applications
  2. Syntax u0026 Comments

    How do you write a single-line comment in JavaScript code?

    1. D. ** this is a comment **
    2. A. u003C!-- this is a comment --u003E
    3. E. ;; this is a comment
    4. C. // this is a comment
    5. B. ## this is a comment
  3. Variables - let

    Which keyword should you use to declare a variable that can be reassigned, such as let x = 5?

    1. B. vlet
    2. A. varible
    3. C. let
    4. E. vart
    5. D. const
  4. Variables - const

    What happens if you try to reassign a variable declared with const in JavaScript?

    1. A. The value updates silently
    2. B. The statement is ignored without any warning
    3. C. A syntax error is thrown
    4. D. The program renames the variable automatically
    5. E. It changes type automatically
  5. Variables - var

    Which JavaScript keyword declares a variable with function scope and allows re-declaration?

    1. A. var
    2. D. val
    3. C. vart
    4. B. let
    5. E. kon
  6. Data Types - String

    Given the code let name = 'Sara';, which JavaScript type does variable name hold?

    1. A. string
    2. C. boolean
    3. E. null
    4. B. number
    5. D. array
  7. Data Types - Number

    What value will typeof 42 return in JavaScript?

    1. C. 'boolean'
    2. D. 'function'
    3. B. 'number'
    4. E. 'object'
    5. A. 'string'
  8. Type Conversion

    What will JavaScript return for Number('25')?

    1. C. 25
    2. E. NaN
    3. B. '25'
    4. D. null
    5. A. 0
  9. Type Conversion - toString

    Which method converts a number to a string in JavaScript, such as (22).toString()?

    1. E. stringy()
    2. A. str()
    3. D. numberToString()
    4. C. toString()
    5. B. toText()
  10. Operators - Arithmetic

    What is the result of the JavaScript expression 3 + 4 * 2?

    1. E. 8
    2. B. 10
    3. D. 7
    4. A. 14
    5. C. 11
  11. Operators - Comparison

    Which operator checks for both value and type equality, such as 5 === '5'?

    1. B. !=
    2. A. ==
    3. C. equals
    4. E. =u003E
    5. D. ===
  12. Operators - Logical

    Which symbol represents the logical AND operator in JavaScript?

    1. C. ^^
    2. E. !u0026
    3. A. u0026u0026
    4. D. u0026
    5. B. ||
  13. Operators - Logical

    What is the result of false || true in JavaScript?

    1. D. false
    2. E. null
    3. C. true
    4. A. undefined
    5. B. 0
  14. Operators - Bitwise

    Which bitwise operator performs a bitwise OR between two numbers in JavaScript?

    1. A. u0026
    2. C. |
    3. B. ^
    4. E. u0026u0026
    5. D. ~
  15. Keywords and Identifiers

    Which of these is NOT a valid variable name in JavaScript?

    1. D. $result
    2. C. 2total
    3. E. userName
    4. B. _score2
    5. A. totalAmount