JavaScript string berisi
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
Cautious Crane
var string = "foo",
substring = "oo";
console.log(string.includes(substring));
var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<input type="text" id='input'>
<button type="button" onclick='btn()'>Alert</button>
<script>
function btn(){
var input=document.getElementById('input').value;
var subs=[
'name','what','child','all','candy'
];
for (let i = 0; i <subs.length; i++) {
if(input.includes(subs[i])){
alert("includes " + subs[i]);
}
else{
console.log('dosnt include '+ subs[i]);
}
}
}
</script>
</body>
</html>