What's supposed to happen is certain profanity typed in and submitted by the user is supposed to be replaced with the censored word.
However, that's not the case. It shows the word without the censor.
Should I use the if/else statements to make this work?
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
var text = document.getElementById('input').value;
var result = document.getElementById('clean');
/* Fake 'bad words' for illustration */
var a = text.replace("ack", "a**");
var ba = text.replace("bandaid", "b******");
var bi = text.replace("butch", "b****");
var f = text.replace("frack", "f****");
var p = text.replace("pee", "p**");
var s = text.replace("shoot", "s****");
var c = text.replace("cart", "c***");
var n = text.replace("night", "n****");
result.innerHTML = text;
}
</script>
</head>
<body>
<textarea id="input"></textarea>
<br />
<input type="submit" onclick="myFunction();" />
<p id="clean"></p>
</body>
</html>