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 141 views
1 answer 132 views
2 answers 154 views
1 answer 143 views
143 views asked Aug 23, 2024 by avibootz
1 answer 131 views
1 answer 117 views
1 answer 188 views
...