forked from M3-Academy/challenge-algorithms-v2.0
19 lines
340 B
JavaScript
19 lines
340 B
JavaScript
export function isAnagram(word1, word2) {
|
|
let testWord1;
|
|
let testWord2;
|
|
|
|
if (word1.length !== word2.length) {
|
|
return false;
|
|
}
|
|
|
|
|
|
testWord1 = word1.toLowerCase('').split('').sort().join('');
|
|
testWord2 = word2.toLowerCase('').split('').sort().join('');
|
|
|
|
if (testWord1 === testWord2) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
|
|
} |