Question 2
Back to Exercise
What happens with "a.b.c".replaceAll(/\./, "-")?
- A It returns "a-b-c"
- B It returns "a-b.c"
- C A TypeError: replaceAll requires a global (g) regex Correct
- D It returns "a.b.c"
Correct Answer: Option C
Calling replaceAll with a non-global regex would be contradictory, so it throws. Write /\./g – or pass the plain 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!