I am trying to insert a generated html form. The stuff to be replaced in this case is every occurance of COMMENTID. For some reason, sometimes when "COMMENTID" is in quotes like that, it does not replace. Why??? How do I fix this?
const htmlstr = `
<form method="post" id="subCommentFormCOMMENTID">
The id of this form is "COMMENTID"
</form>`;
console.log(htmlstr.replace("COMMENTID",4));
This should yield the following:
<form method="post" id="subCommentForm4">
The id of this form is "4"
</form>
But instead it does this:
<form method="post" id="subCommentForm4">
The id of this form is "COMMENTID"
</form>