We are required to write a JavaScript function that takes in two strings as arguments. The function should check for equality of both the strings ignoring their case.
For example −
areEqual('done', 'DOne') should return true.Example
The code for this will be −
const str1 = 'done';
const str2 = 'DOne';
const caseSensitiveCheck = (str1 = '', str2 = '') => {
const loweCase1 = str1.toLowerCase();
const loweCase2 = str2.toLowerCase();
return loweCase1 === loweCase2;
};
console.log(caseSensitiveCheck(str1, str2));Output
And the output in the console will be −
true