I need to replace thousands of #FFF
instances in the string via
Math.floor(Math.random()*16777215).toString(16)
The problem I ran into is that I'm unable to make JS to run this command for each #FFF
in the string, instead, it replaces all #FFF
to a single result.
var string = '1677px 335px #FFF , 59px 1161px #FFF , 850px 963px #46f3b8';
var randomColor = string.replace(/#FFF/g, "#"+Math.floor(Math.random()*16777215).toString(16));
console.log(randomColor);
results in something like:
1677px 335px #46f3b8 , 59px 1161px #46f3b8 , 850px 963px #46f3b8