LearnFrenzy
Sign in Take a free test

Strings · Exercise 1 of 4

Strings JavaScript Strings MCQ

  • 15 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Fifteen multiple-choice questions on JavaScript strings: immutability, quotes and template literals, escape sequences, indexing, Unicode length, slice vs substring, comparison, localeCompare, String() vs toString(), wrapper objects, tagged templates and String.raw. Pick an option to check your answer instantly.

Question 11 Hard

What does a tag function receive in tag`Hello ${name}!`?

A The finished string
B Only the values
C A RegExp
D An array of the literal parts (["Hello ", "!"]) followed by the evaluated values (name)
Question page & discussion
Question 12 Hard

What is the length of String.raw`a\nb`?

A 4 – the backslash and n stay as two characters
B 3 – \n is a new line
C 2
D 5
Question page & discussion
Question 13 Medium

A loop produces 10,000 lines of CSV. Which approach is clear and predictable?

A Push each line into an array and call join("\n") once at the end
B Modify one character of the string at a time with str[i] = …
C Create a new String object for each line
D Use str.reverse() at the end
Question page & discussion
Question 14 Easy

What do "hello".includes("z") and "hello".indexOf("z") return?

A false and 0
B false and -1
C -1 and false
D undefined and -1
Question page & discussion
Question 15 Easy

Which escape sequence puts a line break inside a double-quoted string?

A /n
B \n
C \n written as two backslashes
D <br>
Question page & discussion
Up next · Exercise 2Predict the Output20 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links