2022-10-27 15:07:13 +00:00
|
|
|
export function isAnagram(word1, word2) {
|
2022-10-28 11:15:02 +00:00
|
|
|
let teste, original, cont1 = 0, cont2 = 0;
|
|
|
|
|
|
|
|
teste = word1.split("");
|
|
|
|
original = word2.split("");
|
|
|
|
|
|
|
|
if (teste.length === original.length) {
|
|
|
|
for (let i = 0; i < teste.length; i++) {
|
|
|
|
cont1 = 0;
|
|
|
|
cont2 = 0
|
|
|
|
for (let j = 0; j < teste.length; j++) {
|
|
|
|
if (teste[i].toUpperCase() === teste[j].toUpperCase()) {
|
|
|
|
cont1++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (let k = 0; k < original.length; k++) {
|
|
|
|
if (teste[i].toUpperCase() === original[k].toUpperCase()) {
|
|
|
|
cont2++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cont1 === cont2) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-10-27 15:07:13 +00:00
|
|
|
}
|