From 7ebd8cc90276507b1b764a25ce732f844b5ecbc4 Mon Sep 17 00:00:00 2001 From: Affonsok Date: Sun, 30 Oct 2022 15:29:21 -0300 Subject: [PATCH] =?UTF-8?q?feat(maxValue):=20Responde=20fun=C3=A7=C3=A3o?= =?UTF-8?q?=2003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 03-maxValue/index.js | 1 - 04-fibonacci/index.js | 6 +----- 05-isPrime/index.js | 14 +------------- 06-sum/index.js | 6 +----- 07-sumEven/index.js | 8 +------- 08-isAnagram/index.js | 9 +-------- 09-mostRepeatedChar/index.js | 7 +------ 10-longestWords/index.js | 6 ------ 8 files changed, 6 insertions(+), 51 deletions(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index 0a9a684..ec4d9e6 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,6 +1,5 @@ export function maxValue(values) { // implementar logica aqui - let maxValor = Math.max(...values); if (values == `${[]}`) { return 0 ; diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index c6c1637..716e088 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -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 ] + } \ No newline at end of file diff --git a/05-isPrime/index.js b/05-isPrime/index.js index 0880725..9412ea0 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -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; - } - } + } \ No newline at end of file diff --git a/06-sum/index.js b/06-sum/index.js index 315dafd..1720b26 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -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; + } \ No newline at end of file diff --git a/07-sumEven/index.js b/07-sumEven/index.js index c028c98..cc50779 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -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; + } \ No newline at end of file diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index a27523c..7176c94 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -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(); + } \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index 8baa82c..39bbb19 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -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; + } \ No newline at end of file diff --git a/10-longestWords/index.js b/10-longestWords/index.js index 4eff8ab..1009e7f 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -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 ) ; }