I'm trying to learn how to use backreferences in JavaScript. I have an array and want to replace it within a string.
Here's what I've attempted so far:
var items = ["book", "table"];
var sentence = "The $1 is on the $2";
var newSentence = sentence.replace(items, "$2, $1");
console.log(newSentence);