我们需要编写一个JavaScript函数,该函数接受两个字符串作为参数。该函数应忽略字符串的大小写,检查两个字符串是否相等。
例如-
areEqual('done', 'DOne') should return true.
为此的代码将是-
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));
输出结果
控制台中的输出将是-
true