I've searched but cannot adapt anything to my code. I'm trying to make var toReplace = "warming"
into an array var toReplace = ['global', 'warming']
so it will replace every word from the array in input with var newWord which just wraps the word in a span. thanks for any help!
if (temperature > 90) {
var input = 'ITS GLOBAL EFFING WARMING';
var toReplace = "WARMING";
var emphasisColor = 'cyan';
};
var newWord = `<span style="color: ${emphasisColor}">${toReplace}</span>`;
var regEx = new RegExp(toReplace,"g");
var output = input.replace(regEx, newWord);