How to compare two strings ignoring case in Node.js

2 Answers

0 votes
const str1 = "node.js";
 
const str2 = "NODE.JS";
 
console.log(str1.toUpperCase() === str2.toUpperCase());
 
   
     
     
/*
run:
     
true
     
*/

 



answered May 22, 2024 by avibootz
0 votes
const str1 = "node.js";
 
const str2 = "NODE.JS";
 
console.log(str1.toLowerCase() === str2.toLowerCase());
 
   
     
     
/*
run:
     
true
     
*/

 



answered May 22, 2024 by avibootz

Related questions

1 answer 212 views
1 answer 218 views
1 answer 212 views
1 answer 210 views
1 answer 203 views
1 answer 216 views
1 answer 229 views
...