QuizzesStrings — Templates, Methods and Unicode — Concept Check
intermediate
javascript

Strings — Templates, Methods and Unicode — Concept Check

Questions on Strings — Templates, Methods and Unicode. Template literals handle interpolation and multi-line text; the method set covers most parsing needs. The one trap is that .length counts UTF-16 code units, not characters.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Strings — Templates, Methods and Unicode — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You are using JavaScript to format a SQL query string with variables. Which syntax allows for multi-line strings and variable interpolation?

    • ASingle quotes with concatenation
    • BTemplate literals with backticks
    • CEscape sequences with backslashes
    • DDouble quotes with concatenation
  2. 2.A developer uses the `.length` property on a string containing emoji. What will `.length` return?

    • AThe number of visible symbols
    • BThe number of UTF-16 code units
    • CThe number of bytes
    • DThe number of characters
  3. 3.You have a string 'नमस्ते' and use `.length` to find its length. What will it return?

    • A6
    • B5
    • C3
    • D4
  4. 4.A developer wants to replace all dashes in a string with underscores. Which method should they use?

    • Areplace(/-/)
    • Breplace('-', '_')
    • CreplaceAll('-', '_')
    • Dreplace(/-/g, '_')
  5. 5.What is the result of `['a','b'].join('-')` in JavaScript?

    • A'ab'
    • B'a-b-'
    • C'a,b'
    • D'a-b'
  6. 6.When using `Intl.Collator` for sorting, what is the primary benefit over default string comparison?

    • ACase-insensitive comparison
    • BFaster execution
    • CSimplified syntax
    • DLocale-aware comparison
  7. 7.A developer wants to ensure a string starts with a specific prefix. Which method should they use?

    • Aincludes()
    • Bslice()
    • CstartsWith()
    • Dreplace()