feat: Resolvido questao isAnagram

This commit is contained in:
ThiagoDuutra 2022-10-28 17:04:12 -03:00
parent 8e38569289
commit 5c45023156

View File

@ -1,4 +1,11 @@
export function isAnagram(word1, word2) { export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
//1º => Ver se as strings tem a mesma quantidade de letras
} if (word1.length !== word2.length) {
return false;
}
//2º => Criar duas variáveis para as novas strings
let newTest = word1.toLowerCase().split("").sort().join("");
let newOriginal = word2.toLowerCase().split("").sort().join("");
return newTest === newOriginal;
}