1const fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
2
3const filterItems = (needle, heystack) => {
4 let query = needle.toLowerCase();
5 return heystack.filter(item => item.toLowerCase().indexOf(query) >= 0);
6}
7
8console.log(filterItems('ap', fruits)); // ['apple', 'grapes']
9console.log(filterItems('ang', fruits)); // ['mango', 'orange']