<!DOCTYPE html>
<html>
<body>
<Script>
function checkSpam(str){
str = str.toLowerCase();
let tar1 = "xxx";
let tar2 = "viagra";
let pos = -1;
while( (pos = str.indexOf(tar1, pos + 1) != -1) ){
//condition means when it found
return true;
}
pos = -1;
while( (pos = str.indexOf(tar2, pos + 1) != -1) ){
//condition means when it found
return true;
}
return false;
}
alert(checkSpam('innocent Rabbit') );
</Script>
</body>
</html>
<html>
<body>
<Script>
function checkSpam(str){
str = str.toLowerCase();
let tar1 = "xxx";
let tar2 = "viagra";
let pos = -1;
while( (pos = str.indexOf(tar1, pos + 1) != -1) ){
//condition means when it found
return true;
}
pos = -1;
while( (pos = str.indexOf(tar2, pos + 1) != -1) ){
//condition means when it found
return true;
}
return false;
}
alert(checkSpam('innocent Rabbit') );
</Script>
</body>
</html>
댓글
댓글 쓰기