feat(isAnagram): Feito o oitavo exercício

This commit is contained in:
Vinícius Gabriel 2022-10-28 08:15:02 -03:00
parent 352ebbe159
commit dffee7f77e

View File

@ -1,4 +1,32 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
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
}
}