This code will take str and put each word in a <span>. I want to add some functionality, so some words will be highlighted, but can't figure out how to pass $& (which is a word) to the highLight function. Right now I have written {$&} which does not work.
str = "Adam Sandler"
const highLight = (param) => {
conosle.log(param)
}
const wrapWordsInSpan = (str) => {
const addedSpanToText = str.replace(
/\w+/g,
`<span id="text-container" style="color: ${highLight(`{$&}`)}"}>$&</span>`
);