How to compare two strings ignoring case in JavaScript

2 Answers

0 votes
const str1 = "javascript";

const str2 = "JAVASCRIPT";

console.log(str1.toUpperCase() === str2.toUpperCase());

  
    
    
/*
run:
    
true
    
*/

 



answered Jun 5, 2021 by avibootz
0 votes
const str1 = "javascript";

const str2 = "JAVASCRIPT";

console.log(str1.toLowerCase() === str2.toLowerCase());

  
    
    
/*
run:
    
true
    
*/

 



answered Jun 5, 2021 by avibootz

Related questions

1 answer 221 views
1 answer 234 views
2 answers 280 views
1 answer 238 views
238 views asked Aug 23, 2024 by avibootz
1 answer 226 views
1 answer 220 views
1 answer 287 views
...