diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..5c0279c 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}`; } diff --git a/02-triangleArea/index.js b/02-triangleArea/index.js index 7628fcd..475c5ab 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,4 @@ export function triangleArea(base, height) { - // your code here + var area = (base*height) / 2 + return area } \ No newline at end of file diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..7ad07d1 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,7 @@ 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 diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..4f10945 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 fib1 = 0 + let fib2 = 1 + let fibN = value + for (let i = 2; i <=value; i++){ + fibN = fib2 + fib1 + fib1 = fib2 + fib2 = fibN + } + return fibN } \ No newline at end of file diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..c6526a4 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,9 @@ export function sum(values) { // implementar logica aqui + var soma = 0; + for (var i = 0; i < values.length; i++) { + soma += values[i]; + } + return soma; } \ No newline at end of file diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..8dba971 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,12 @@ export function sumEven(value) { // implementar logica aqui - + const pares = value; + var i; + let soma = 0; + for (i = 0; i <= pares.length; i++) { + if (pares[i] % 2 === 0) { + soma = soma + pares[i]; + } + } + return soma; } \ No newline at end of file diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..dc5da45 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,6 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + word1 = word1.toUpperCase().split('').sort().join(''); + word2 = word2.toUpperCase().split('').sort().join(''); + return word1 === word2 } \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..756bb7e 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,18 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + 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 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