From 58830aba2f44446cf90613e19c6131465924127a Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:23:16 -0300 Subject: [PATCH 01/10] feat(desafio01):desafio-completo --- 01-greeting/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..544b5f1 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,4 @@ export function greet(name) { // implementar logica aqui - return ""; + return `Hello ${name}` } -- 2.34.1 From e34c4c6cb36ca9a8d57146cc6583bdebd1aab2fe Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:52:27 -0300 Subject: [PATCH 02/10] feat(desafio02):desafio-completo --- 02-triangleArea/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..319154f 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,5 @@ -export function triangleArea(base, height) { +export function triangleArea(base, height) { // your code here + let area = base * height / 2 + return area } \ No newline at end of file -- 2.34.1 From 4e0a8ab21b4af5234e02bad6b7f03e623f14b72d Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:18:46 -0300 Subject: [PATCH 03/10] feat(desafio03):desafio-completo --- 03-maxValue/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..b278e4c 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,10 @@ export function maxValue(values) { // implementar logica aqui - + if (values.length === 0) { + + return 0; + } + + return Math.max.apply(null,values); + } \ No newline at end of file -- 2.34.1 From a0e3f1c4a5848eaf68c3275a7669192cd08cec17 Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:25:39 -0300 Subject: [PATCH 04/10] feat(desafio04):desafio-completo --- 04-fibonacci/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..c111ec9 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,14 @@ export function fibonacci(value) { // implementar logica aqui - + if (value < 1) return 0 + if (value <= 2) return 1 + let fibMinus2 = 0 + let fibMinus1 = 1 + let fibN = value + for (let i = 2; i <=value; i++){ + fibN = fibMinus1 + fibMinus2 + fibMinus2 = fibMinus1 + fibMinus1 = fibN + } + return fibN } \ No newline at end of file -- 2.34.1 From af4f3269cc2be38f5ed08b6e18bef52254a3e0dd Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:31:56 -0300 Subject: [PATCH 05/10] feat(desafio05):desafio-completo --- 05-isPrime/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..b3b6f2a 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,13 @@ export function isPrime(value) { // implementar logica aqui - + if(value == 0 || value == 1) { + return false +} + +for(let div = 2; div <= Math.sqrt(value); div++){ + if(value % div == 0) { + return false + } +} +return true } \ No newline at end of file -- 2.34.1 From 4a24ab356320522ab672da2bc45b9eed1ce08286 Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:39:05 -0300 Subject: [PATCH 06/10] feat(desafio06):desafio-completo --- 06-sum/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..ebdc89d 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,13 @@ export function sum(values) { // implementar logica aqui - + if (values.length === 0) { + + return 0; + } + + let sum = values.reduce(function(accumulator,value){ + return accumulator + value; +}) + +return sum } \ No newline at end of file -- 2.34.1 From 2415e944a03e7c640efed7db1fefc9a1c2017ceb Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:42:47 -0300 Subject: [PATCH 07/10] feat(desafio07):desafio-completo --- 07-sumEven/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8fff8f4 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,13 @@ export function sumEven(value) { // implementar logica aqui - -} \ No newline at end of file + const newArray = value; + var i; + let total = 0; + + for (i = 0; i < newArray.length; i++) { + if (newArray[i] % 2 === 0) { + total = total + newArray[i]; + } + } + return total; +} \ No newline at end of file -- 2.34.1 From 14cf4ae60944fc3ac489b63174f8f57aecf0a95e Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:49:59 -0300 Subject: [PATCH 08/10] feat(desafio08):desafio-completo --- 08-isAnagram/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..62700e1 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,6 @@ export function isAnagram(word1, word2) { // implementar logica aqui - -} \ No newline at end of file + word1 = word1.toUpperCase().split('').sort().join(''); + word2 = word2.toUpperCase().split('').sort().join(''); + return word1 === word2 + } \ No newline at end of file -- 2.34.1 From f207e8a5cd32d94f7bce52ebc2df26b9fc30dcf1 Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Fri, 28 Oct 2022 10:53:09 -0300 Subject: [PATCH 09/10] feat(desafio09):desafio-completo --- 09-mostRepeatedChar/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..e7d6fdf 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,19 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" -} \ No newline at end of file + let result = ''; + let mostUsedCount = 0; + for (const letter of text) { + let countLetter = 0; + for (const letterToCount of text) { + if (letterToCount === letter) { + countLetter++; + } + } + if (countLetter > mostUsedCount) { + mostUsedCount = countLetter; + result = letter; + } + } + + return result; + } \ No newline at end of file -- 2.34.1 From 50c4836b9ae8fb370434925f4e44366e60b0cccf Mon Sep 17 00:00:00 2001 From: Nicolas Oliveira <110689312+thedevnicolas@users.noreply.github.com> Date: Sat, 29 Oct 2022 09:24:01 -0300 Subject: [PATCH 10/10] feat(desafio10):desafio-completo --- 10-longestWords/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..d17f723 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,14 @@ export function longestWords(words) { // implementar logica aqui - + let newArr = []; + let long = 0; + words.forEach(function(element){ + if(element.length > long){ + long = element.length + } + }); + newArr = words.filter(element => + element.length == long + ); + return newArr; } \ No newline at end of file -- 2.34.1