Question 2
Back to Exercise
What does the following JavaScript code print (console output, as in Node.js)?
console.log("price: 50 and 75".replace(/\d+/g, "₹$&"));
- A price: ₹50 and ₹75 Correct
- B price: ₹$& and ₹$&
- C price: ₹50 and 75
- D price: ₹ and ₹
Correct Answer: Option A
$& inserts the whole matched text, so each number is kept and prefixed with ₹.
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!