Course: JavaScript

Progress (0%)

  1. Foundation

  2. Numbers

  3. Strings

  4. Conditions

  5. Loops

  6. Arrays

  7. Functions

  8. Objects

  9. Exceptions

  10. HTML DOM

  11. CSSOM

  12. Events

  13. Drag and Drop

  14. opt Touch Events

  15. Misc

  16. Project: Analog Clock

JavaScript Strings Quiz

Quiz 7 9 questions

Prerequisites for the quiz

  1. Whole JavaScript Strings unit

Are you ready?

9 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
In which of the following ways can we create strings in JavaScript?
Refer to Strings Basic Concepts for more info.
Determine the error in the code below.
var str = "Hello\n
World";
Refer to Strings Basic Concepts for more info.
What is the best description of the problem in the code below?
var str = "Hello World";
str[0] = "F";
Strings are immutable and hence can't be modified as shown in the code snippet above. Refer to Strings Basic Concepts for more info.
How to convert a string str to lowercase characters?
Refer to Strings Properties and Methods for more info.
What does the following code log?
var str = "I love cats!";
console.log(str.indexOf("cat"));
The 'c' in "cat" comes at index 7 in str - hence we get 7 returned by str.indexOf("cat"). Refer to Strings Properties and Methods for more info.
What does the following code log?
var str = "Twice a day";
var index = str.indexOf("a");
var index2 = str.lastIndexOf("a");
console.log(str.indexOf("a", index + 1) === index2);
Refer to Strings Properties and Methods for more info.
How can we extract "Pizza" from the string str = "Pizza Lover"?
Refer to Strings Properties and Methods for more info.
What does str.charAt(1) return for the string str = "Hello"?
Refer to Strings Properties and Methods for more info.
Suppose that str is equal to the string "Mango Apple Orange". What will str.split() return?
If split() is called on a string without an argument, it returns an array with exactly one element that is the string itself. Refer to Strings Properties and Methods for more info.