var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];
function filterItems(query) { // this would be 'ap' in the example below
return fruits.filter(function(el) { // is the el the full value from fruits array passed in? so, 'apple', etc.
return el.toLowerCase().indexOf(query.toLowerCase()) > -1;
// same as 'ap'.toLowerCase().indexOf('apple'.toLowerCase()) > -1
// why is it -1? what does it mean here?
})
}
console.log(filterItems('ap')); // ['apple', 'grapes']
console.log(filterItems('an')); // ['banana', 'mango', 'orange']