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

20 lines
430 B
JavaScript

export function isAnagram(word1, word2) {
// implementar logica aqui
let par_1 = word1.toLowerCase().split("").sort();
let par_2 = word2.toLowerCase().split("").sort();
let final;
if (par_1.length != par_2.length) {
final = "false";
} else {
for (i in par_1) {
if (par_1[i] != par_2[i]) {
final = "false";
break;
} else {
final = "true";
}
}
}
return final;
}