Verifique se há javascript de substring
const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //true
Batman
const string = "javascript";
const substring = "script";
console.log(string.includes(substring)); //true
'a nice string'.includes('nice') //true
'a nice string'.includes('nice', 3) //false
'a nice string'.includes('nice', 2) //true
stringVariable.includes("Your Text");
<!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>