feat(sumEven and isAnagram): Implementa função que retorna a soma dos números pares de um array e outra que checa se as palavras são anagramas

This commit is contained in:
Saulo Klein Nery 2022-10-28 13:02:42 -03:00
parent d1b51a6e2a
commit 0ce54d3738
2 changed files with 18 additions and 2 deletions

View File

@ -1,4 +1,12 @@
export function sumEven(value) {
// implementar logica aqui
let soma = 0;
value.map(
(element) => {
if(element % 2 === 0)
soma += element;
}
);
return soma;
}

View File

@ -1,4 +1,12 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
return putOnUnicodeOrder(word1) === putOnUnicodeOrder(word2);
}
function putOnUnicodeOrder(string){
return string
.toLowerCase()
.split("")
.sort()
.join("");
}