How to compare two strings ignoring case in TypeScript

2 Answers

0 votes
const str1: string = "typescript";
 
const str2: string = "TYPESCRIPT";
 
console.log(str1.toUpperCase() === str2.toUpperCase());
 
   
     
     
/*
run:
     
true
     
*/

 



answered May 22, 2024 by avibootz
0 votes
const str1: string = "typescript";
 
const str2: string = "TYPESCRIPT";
 
console.log(str1.toLowerCase() === str2.toLowerCase());
 
   
     
     
/*
run:
     
true
     
*/

 



answered May 22, 2024 by avibootz

Related questions

1 answer 222 views
1 answer 234 views
2 answers 281 views
1 answer 239 views
239 views asked Aug 23, 2024 by avibootz
1 answer 227 views
1 answer 220 views
1 answer 287 views
...