feat(isAnagram): compara dois parametros e avalia se sao anagramas

This commit is contained in:
Vinicius 2022-11-02 21:05:29 -02:00
parent 79e31fb5d0
commit 7439433cff

View File

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