javascript string includes case insensitive code example
Example 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);
Example 2: Javascript case insensitive string comparison
var name1 = "Taylor Johnson";
var name2 ="taylor johnson";
if(name1.toLowerCase() === name2.toLowerCase()){
}
Example 3: javascript string search case insensitive
function stringContainsCaseInsensitive(search, subject){
return subject.toLowerCase().indexOf(search.toLowerCase()) !== -1;
}
stringContainsCaseInsensitive("red","We painted the room red.");
Example 4: js includes case insensitive
var passedinstring = localStorage.getItem("passedinstring").toLowerCase();