Question 13
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("Banana".indexOf("b"), "Banana".toLowerCase().indexOf("b"), "Banana".lastIndexOf("an"));
- A 0 0 3
- B -1 0 1
- C -1 0 3 Correct
- D 0 -1 4
Correct Answer: Option C
indexOf is case-sensitive, so lower-case "b" is not found in "Banana". The last "an" starts at index 3.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!