Question 5
Back to Exercise
For const s = "Hello";, what are s.slice(-3) and s.substring(-3)?
- A "llo" and "llo"
- B "Hel" and "Hello"
- C "llo" and "Hello" Correct
- D "Hello" and "llo"
Correct Answer: Option C
slice counts negative indexes from the end; substring treats negatives as 0, so it returns the whole string.
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!