Merge pull request 'lorenacoelho' (#1) from lorenacoelho into master

Reviewed-on: #1
This commit is contained in:
Lorena Camila Coelho Máximo 2022-11-03 00:56:24 +00:00
commit 69449ed1c2
11 changed files with 48 additions and 11 deletions

View File

@ -1,4 +1,4 @@
export function greet(name) {
// implementar logica aqui
return "";
return "Hello " + name;
}

View File

@ -1,3 +1,3 @@
export function triangleArea(base, height) {
// your code here
return (base*height)/2
}

View File

@ -1,4 +1,4 @@
export function maxValue(values) {
// implementar logica aqui
return values?.length ? Math.max(...values) : 0
}

View File

@ -1,4 +1,13 @@
export function fibonacci(value) {
// implementar logica aqui
let resultado = 0
let anterior = 0
let proximo = 1
for (let i = 0; i < value; i++) {
resultado = anterior + proximo
anterior = proximo
proximo = resultado
}
return anterior
}

View File

@ -1,4 +1,9 @@
export function isPrime(value) {
// implementar logica aqui
for (let i = 2; i < value; i++)
if (value % i === 0) {
return false;
}
return value > 1
}

View File

@ -1,4 +1,9 @@
export function sum(values) {
// implementar logica aqui
let total = 0;
for (let i = 0; i < values.length; i++) {
total += values[i]
}
return total
/* return values.reduce((acumulador, valorAtual) => acumulador + valorAtual, 0) */
}

View File

@ -1,4 +1,10 @@
export function sumEven(value) {
// implementar logica aqui
let total = 0;
for (let i = 0; i < value.length; i++) {
if (value[i] % 2 === 0) {
total += value[i];
}
}
return total
}

View File

@ -1,4 +1,4 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
return word1.length !== word2.length ? false : word1.toLowerCase().split('').sort().join('') === word2.toLowerCase().split('').sort().join('')
}

View File

@ -1,4 +1,9 @@
export function mostUsedChar(text) {
// implementar logica aqui
return ""
let strObj = {}
return text.replaceAll(' ', '').toLowerCase().split('').reduce(
(letraAnterior, letraAtual) => {
strObj[letraAtual] = strObj[letraAtual] + 1 || 1
return strObj[letraAnterior] > strObj[letraAtual] ? letraAnterior : letraAtual
})
}

View File

@ -1,6 +1,6 @@
# Desafio 04: caractere mais repetido
Faça um algoritmo que retorne a a letra mias repetida de uma string
Faça um algoritmo que retorne a letra mais repetida de uma string
## Exemplo

View File

@ -1,4 +1,11 @@
export function longestWords(words) {
// implementar logica aqui
return words.reduce((acumulador, palavraAtual) => {
if (!acumulador.length) acumulador = [palavraAtual];
else if (palavraAtual.length > acumulador[0].length)
acumulador = [palavraAtual];
else if (palavraAtual.length === acumulador[0].length)
acumulador = [...acumulador, palavraAtual];
return acumulador;
}, [])
}