How to perform case-insensitive two strings comparison in TypeScript

1 Answer

0 votes
function equalsIgnoreCase(str1: string, str2: string) {
    return str1.toLowerCase() === str2.toLowerCase();
}

const str1: string = "profession: typescript Programmer";
const str2: string = "Profession: TypeScript PROGRAMMER";

const equals: boolean = equalsIgnoreCase(str1, str2);

console.log(equals);


   
/*
run:
   
true
  
*/

 



answered Feb 24, 2025 by avibootz

Related questions

1 answer 93 views
1 answer 100 views
1 answer 89 views
1 answer 106 views
1 answer 83 views
1 answer 88 views
...