forked from M3-Academy/challenge-algorithms-v2.0
29 lines
315 B
JavaScript
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|