LearnFrenzy
Sign in Take a free test

String Methods · Predict the Output · Question 11

includes with case and positions Answer, explanation & discussion

  • Output
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 11 Back to Exercise

What does the following JavaScript code print (console output, as in Node.js)?

main.js
const s = "JavaScript";
console.log(s.includes("script"), s.includes("Script", 4), s.includes("Script", 5));
  • A true true false
  • B false true true
  • C false false false
  • D false true false Correct
Correct Answer: Option D

includes is case-sensitive. "Script" starts at index 4, so a search from 4 finds it and a search from 5 does not.

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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links