The issue here is that you are not saving the result of textContent.replace(word, '')
. the replace
function does not modify the textContent
variable in place; rather the result is returned.
Thus, you need to save the results back to textContent
. So
textContent.replace(word, '')
should be:
textContent = textContent.replace(word, '')