Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

indexof case insensitive javascript

// First approach: convert all letters to either uppercase or lowercase
const favorite = "JavaScript";
const languages = "JavaScript, Python, and C#";
if (languages.toUpperCase().indexOf(favorite.toUpperCase()) !== -1) {
	console.log(`${favorite} is listed`);
} else {
  console.log(`${favorite} is not listed`);
}
// Alternatively, a regular expression can be used
const pattern = /Java/i; // i => ignore case flag
if(pattern.test(languages)) {
  console.log(`${favorite} is listed`);
} else {
console.log(`${favorite} is not listed`);
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: js add params to url 
Javascript :: getelementbytagname javascript 
Javascript :: palindrome in javascript 
Javascript :: scroll page to top after ajax success 
Javascript :: find the missing value in an integer array javascript 
Javascript :: jquery append img to div 
Javascript :: jq html remove disabled 
Javascript :: most 5 spoken language in countries array in js 
Javascript :: parse date do weekday 
Javascript :: convert buffer to base64 javascript 
Javascript :: jQuery search immediate children 
Javascript :: disable right click html w3schools 
Javascript :: Firebase CLI v11.0.1 is incompatible with Node.js v14.17.6 Please upgrade Node.js to version = 14.18.0 
Javascript :: find last element with class jquery 
Javascript :: how to fix eslint error no-prototype-builtins 
Javascript :: javascript json upload 
Javascript :: vuejs watch sub property 
Javascript :: settimeout arrow function javascript 
Javascript :: trigger ctrl + p or print page with javascript 
Javascript :: convert string to datetime javascript 
Javascript :: js onchange paramteter sring 
Javascript :: regex char any quantity 
Javascript :: check jquery version on console 
Javascript :: javascript iterate over json 
Javascript :: add class on javascript onclick function 
Javascript :: react app.js 
Javascript :: python http request post json example 
Javascript :: how to take create array using jquery 
Javascript :: loop through object javascript 
Javascript :: remove special characters javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =