Question 3
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("learn java script now".replace(/\b\w/g, (c) => c.toUpperCase()));
- A Learn Java Script Now Correct
- B LEARN JAVA SCRIPT NOW
- C Learn java script now
- D learn java script now
Correct Answer: Option A
\b\w matches the first character of each word, and the function upper-cases each match.
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!