I searched about this and all I found is that all answers contains indexof, which for some reason does not work in my option:
I have an array:
var array = ["Sunny","Snowy","Rainy"];
var input = document.getElementById('input').value;
Now When I use indexOf it works only when I input the whole word, I need it in way:
Input: S
Result: Sunny, Snowy
Input: Su
Result: Sunny
Here is the code:
for (var i = 0; i < array.length; i++) {
if (input.indexOf(array[i])> -1) {
console.log("Object with index number "+i+" contains "+input);
}
return;
}
Just plain javascript without jquery.