Question 12
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
const file = "index.html";
console.log(file.endsWith("index", 5), file.startsWith("html", 6), file.endsWith(".htm"));
- A true true false Correct
- B false true false
- C true false true
- D false false false
Correct Answer: Option A
endsWith("index", 5) treats the string as "index"; startsWith("html", 6) starts checking at index 6. The full name ends in ".html", not ".htm".
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!