0
Check a array for bad words?
Hello! I just made a code wich will check if the user input has bad words. As you can see, the bad words are in a array and the only word that is being blocked is the 3rd one, "cu". http://code.sololearn.com/WyWCarn692iw/#js As it seems, my code is not searching all the words in the array, but taking the last one. Thanks!
3 odpowiedzi
+ 1
hi
add :
-> break; at the end of the if bloc;
and your test condition only needs :
-> if (pegaTexto.value.toLowerCase() === ofensa[i])
+ 1
if (pegaTexto.value.toLowerCase() === ofensa[i]) {
document.getElementById('alerta').style.display = "block";
document.getElementById('alerta').style.backgroundColor=#ff0000";
document.getElementById('alerta').innerHTML = alertaTextoErr;
break;
}
0
Thank you for the help, it works fine now!!!