Advanced JavaScript: Strings, Numbers, and Dates Quiz — Questions & Answers

Challenge your expertise on JavaScript string, number, and date methods, including edge cases and tricky behaviors. This quiz is designed for those wanting to validate their deep understanding of these core JavaScript concepts.

This quiz contains 15 questions. Below is a complete reference of all questions, answer choices, and correct answers. You can use this section to review after taking the interactive quiz above.

  1. Question 1: String Immutability and Methods

    Given const str = 'abc'; what will be the new value of str after performing str.toUpperCase(); ?

    • null
    • 'abc'
    • 'Abc'
    • undefined
    • 'ABC'
    Show correct answer

    Correct answer: 'abc'

  2. Question 2: Template Literals and Expression Evaluation

    What is the output of the following code? const x = 5; const y = 10; console.log(`Sum: ${x + y}`);

    • Sum: 510
    • Sum: x + y
    • Sum: 5 + 10
    • Sum: 15
    • `Sum: 15`
    Show correct answer

    Correct answer: Sum: 15

  3. Question 3: Number Object: isNaN and Edge Cases

    What will Number.isNaN('NaN') evaluate to in JavaScript?

    • undefined
    • TypeError
    • true
    • null
    • false
    Show correct answer

    Correct answer: false

  4. Question 4: Math Object Randomization

    What is the possible range of values (inclusive or exclusive) returned by Math.random() in standard JavaScript?

    • [0, 1)
    • (0, 1]
    • [0.1, 1)
    • [0, 1]
    • (0, 1)
    Show correct answer

    Correct answer: [0, 1)

  5. Question 5: Split and Limits in String Methods

    What will be the output of 'banana,apple,pear'.split(',', 2)?

    • ['banana', 'applepear']
    • ['banana']
    • ['banana', 'apple', 'pear']
    • ['banana', 'apple']
    • ['banana,apple']
    Show correct answer

    Correct answer: ['banana', 'apple']

  6. Question 6: Comparing Numbers: Precision Issues

    What is the result of 0.1 + 0.2 === 0.3 in JavaScript?

    • true
    • false
    • TypeError
    • null
    • undefined
    Show correct answer

    Correct answer: false

  7. Question 7: Date Object: UTC and Local Time

    If you create a date object as new Date(Date.UTC(2020, 0, 1)), what will date.getUTCFullYear() return?

    • 0
    • 2021
    • 2019
    • 2020
    • January
    Show correct answer

    Correct answer: 2020

  8. Question 8: String Search Methods: lastIndexOf

    For the string 'abracadabra', what is the result of str.lastIndexOf('a', 5)?

    • 0
    • 10
    • 5
    • 3
    • 7
    Show correct answer

    Correct answer: 5

  9. Question 9: Math Object: Math.ceil Edge

    What does Math.ceil(-2.3) return?

    • -3
    • 0
    • 3
    • -2
    • 2
    Show correct answer

    Correct answer: -2

  10. Question 10: Converting Dates to ISO Strings

    What is the output type of date.toISOString() when date is a valid Date object?

    • Number
    • Array
    • Date
    • Object
    • String
    Show correct answer

    Correct answer: String

  11. Question 11: String padStart and padEnd

    What is the result of '7'.padStart(3, '0').padEnd(5, '8')?

    • '00788'
    • '70088'
    • '78008'
    • '00778'
    • '07888'
    Show correct answer

    Correct answer: '00788'

  12. Question 12: Parsing Integers with parseInt

    What value is returned by parseInt('09', 8) in JavaScript?

    • 1
    • NaN
    • 8
    • 9
    • 0
  13. Question 13: Date Methods: getDay vs getDate

    For new Date('2024-06-13'), what does date.getDay() return if June 13, 2024, is a Thursday?

    • 13
    • 6
    • 3
    • 5
    • 4
    Show correct answer

    Correct answer: 4

  14. Question 14: Identifying Infinite Numbers

    What does Number.isFinite(Infinity) return?

    • NaN
    • null
    • false
    • true
    • undefined
    Show correct answer

    Correct answer: false

  15. Question 15: String.replace and Regular Expressions

    What will be the result of 'test-test'.replace(/t/g, 's')?

    • 'sesl-sesl'
    • 'ses-ses'
    • 'sest-sest'
    • 'tess-tess'
    • 'sess-sess'
    Show correct answer

    Correct answer: 'ses-ses'