I want to replace some words in string. I have got working solution but I don't think it's the best one. Could you please help me with more effective & clever solution (less code)?
The code is avaiable live here: https://codepen.io/yasAFE/pen/BYOVme
function main() {
var input = document.getElementById("input");
var output = input.value.replace(/red/gi, "blue") // how to write this but
.replace(/bad/gi, "good") // with less code?
.replace(/girl/gi, "boy")
.replace(/gold/gi, "metal");
input.value = output;
}
<textarea id="input" spellcheck="false" autocorrect="off"></textarea>
<button class="button" onclick="main()">Transform my text</button>