Why we use query.toLowerCase() in this code

I am trying to understand the second toLowerCase .Here is the code.

var fruits = ['apple', 'banana', 'grapes', 'mango', 'orange'];

function filterItems(query) {
  return fruits.filter(function(el) {
    return el.toLowerCase().indexOf(query.toLowerCase()) > -1;
  })
}

console.log(filterItems('ap')); // ['apple', 'grapes']

82 thoughts on “Why we use query.toLowerCase() in this code”

Leave a Comment