challenge-algorithms-v2.0-l.../08-isAnagram/index.js

19 lines
340 B
JavaScript
Raw Normal View History

export function isAnagram(word1, word2) {
2022-11-02 17:23:55 +00:00
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;
}