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

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;
}