feat(maxValue): Responde função 03

This commit is contained in:
Affonso Kopmann 2022-10-30 15:29:21 -03:00
parent fe0dcf6866
commit 7ebd8cc902
8 changed files with 6 additions and 51 deletions

View File

@ -1,6 +1,5 @@
export function maxValue(values) {
// implementar logica aqui
let maxValor = Math.max(...values);
if (values == `${[]}`) {
return 0 ;

View File

@ -1,8 +1,4 @@
export function fibonacci(value) {
// implementar logica aqui
let arr = [ 0, 1 ];
for (let i = 2; i < value + 1; i++) {
arr.push ( arr [ i - 2 ] + arr [ i - 1 ] )
}
return arr [ value ]
}

View File

@ -1,16 +1,4 @@
export function isPrime(value) {
// implementar logica aqui
{ if ( value === 1 ) {
return false;
} else if ( value === 2 ) {
return true;
} else {
for ( var x = 2; x < value; x++ ) {
if ( value % x === 0 ) {
return false;
}
}
return true;
}
}
}

View File

@ -1,8 +1,4 @@
export function sum(values) {
// implementar logica aqui
let soma = 0;
for( let index = 0; index < values.length; index += 1 ) {
soma = soma + values [ index ] ;
}
return soma;
}

View File

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

View File

@ -1,11 +1,4 @@
export function isAnagram(word1, word2) {
// implementar logica aqui
if (cleanString(word1) === cleanString(word2)) {
return true;
} else {
return false;
};
}
function cleanString(str) {
return str.toLowerCase().split('').sort().join();
}

View File

@ -1,9 +1,4 @@
export function mostUsedChar(text) {
// implementar logica aqui
let hashmap = {}, resposta;
text.split('').reduce((acumulador, letra) => {
hashmap [ letra ] = hashmap [ letra ] + 1 || 1
resposta = hashmap [ letra ] >= acumulador ? letra : resposta
return acumulador = hashmap [ letra ] > acumulador ? acumulador + 1 : acumulador }, 1 )
return resposta;
}

View File

@ -2,10 +2,4 @@ import { arrayBuffer } from "stream/consumers";
export function longestWords(words) {
// implementar logica aqui
let maioresPalavras = "";
for ( const word of words ) {
if ( word.length > maioresPalavras.length ) {
maioresPalavras = word; }
}
return words.filter ( ( word ) => word.length == maioresPalavras.length ) ;
}