Answers for "array.includes case insensitive"

1

array contains case insensitive javascript

var array = ['I', 'hAve', 'theSe', 'ITEMs'],
    query = 'these',
    result = array.findIndex(item => query.toLowerCase() === item.toLowerCase());

console.log(result); // 2
Posted by: Guest on April-01-2020
1

javascript includes case insensitive

stringtodetect.toLowerCase().includes("stringtocompare");

// OR, Alternatively...
stringtodetect.toLowerCase().includes(variable.toLowerCase());
Posted by: Guest on September-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language