is my syntax correct i wanted to replace string in pattern abcd+abcd+ but its not working using replace method in JavaScript here is the code snapshot the commented one dose not work which i require
function myFunction() {
var str = document.getElementById("demo").innerText;
//var res = str.replace(/+/g, "red");
var res2 = str.replace("+", "red");
document.getElementById("demo").innerText = res2;
}
<p>Click the button to replace "blue" with "red" in the paragraph below:</p>
<p id="demo">Mr + has a + house and a blue car.</p>
<button onclick="myFunction()">Try it</button>