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

29 lines
315 B
JavaScript

export function isAnagram(word1, word2) {
if (word1.length !== word2.length) {
return false;
} else {
if (
word1.toLowerCase().split("").sort().join("") ===
word2.toLowerCase().split("").sort().join("")
) {
return true;
} else {
return false;
}
}
}