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..83e0908 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,4 @@ export function triangleArea(base, height) { // your code here + return base * height /2 } \ No newline at end of file diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..2327b0d 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,8 @@ export function maxValue(values) { // implementar logica aqui - + if (values.length == 0){ + return 0 + }else{ + return Math.max(...values) + } } \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..357ed12 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,8 @@ export function fibonacci(value) { // implementar logica aqui - + const fibo = [0, 1] + for (let i = 2; i <= value; i++) { + fibo[i] = fibo[i-1] + fibo[i-2] + } + return fibo[value] } \ No newline at end of file diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..3d7d0c7 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,6 @@ export function isPrime(value) { // implementar logica aqui - + for (let div = 2; div < value; div++) + if (value % div == 0) return false; + return true; } \ No newline at end of file diff --git a/06-sum/index.js b/06-sum/index.js index ebc2ee1..902f0e1 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,6 @@ export function sum(values) { // implementar logica aqui - + let sums = 0; + values.forEach(item => sums += item); + return sums } \ No newline at end of file diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..53005ea 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,7 @@ export function sumEven(value) { // implementar logica aqui - + let sums = 0; + value.forEach(item => { + if(item%2==0) sums += item;}); + return sums } \ No newline at end of file diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..64b56b2 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,14 @@ export function isAnagram(word1, word2) { // implementar logica aqui - + if(word1.length == word2.length){ + const words1 = word1.toUpperCase().split("").sort(); + const words2 = word2.toUpperCase().split("").sort(); + if (words1.join() == words2.join()){ + return true + }else { + return false + } + } else { + return false + } } \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..8a25df1 100644 --- a/09-mostRepeatedChar/index.js +++ b/09-mostRepeatedChar/index.js @@ -1,4 +1,9 @@ export function mostUsedChar(text) { // implementar logica aqui - return "" + let words = {} + const texts = text.toLowerCase().split("").sort(); + texts.forEach((word) => words[word] = (words[word] || 0) + 1); + const maxVal = Math.max(...Object.values(words)); + const word = Object.keys(words).find((key) => words[key] === maxVal); + return word } \ No newline at end of file diff --git a/10-longestWords/index.js b/10-longestWords/index.js index a98d2d8..1118c26 100644 --- a/10-longestWords/index.js +++ b/10-longestWords/index.js @@ -1,4 +1,10 @@ export function longestWords(words) { // implementar logica aqui - + let longestSize = 0 + let longestWord = [] + words.forEach(element => { + if(element.length>longestSize) + {longestSize = element.length}}) + longestWord = words.filter(element => element.length === longestSize); + return longestWord } \ No newline at end of file