diff --git a/01-greeting/index.js b/01-greeting/index.js index 8f551af..021dae1 100644 --- a/01-greeting/index.js +++ b/01-greeting/index.js @@ -1,4 +1,3 @@ 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..4cc7b32 100644 --- a/02-triangleArea/index.js +++ b/02-triangleArea/index.js @@ -1,3 +1,5 @@ export function triangleArea(base, height) { - // your code here + let result; + result = (base * height) / 2; + return result; } \ No newline at end of file diff --git a/03-maxValue/index.js b/03-maxValue/index.js index e433b31..c195ce1 100644 --- a/03-maxValue/index.js +++ b/03-maxValue/index.js @@ -1,4 +1,15 @@ export function maxValue(values) { - // implementar logica aqui + let max = 0; + max = values[0]; + if (values.length === 0){ + return 0; + } + + for(let i= 0; i < values.length; i++) { + if (values[i] > max) { + max = values[i]; + } +} + return max; } \ No newline at end of file diff --git a/04-fibonacci/index.js b/04-fibonacci/index.js index 37c64cc..c0602cd 100644 --- a/04-fibonacci/index.js +++ b/04-fibonacci/index.js @@ -1,4 +1,14 @@ export function fibonacci(value) { - // implementar logica aqui + // + let previous = 0; + let sum = 0; + let next = 1; + + for (let i = 0; i < value; i++) { + sum = previous + next; + previous = next; + next = sum; + } + return previous; } \ No newline at end of file diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..09d6377 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,17 @@ export function isPrime(value) { - // implementar logica aqui + if(value <= 1){ + return false; + } -} \ No newline at end of file + for (let i = 2; i < value; i++ ){ + if (value % i === 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..1c56f1b 100644 --- a/06-sum/index.js +++ b/06-sum/index.js @@ -1,4 +1,6 @@ export function sum(values) { - // implementar logica aqui - + let sumAll = 0; + for (let i = 0; i < values.length; i++) { + sumAll = sumAll + values[i]; + } return sumAll; } \ No newline at end of file diff --git a/07-sumEven/index.js b/07-sumEven/index.js index bb1e095..fc7e880 100644 --- a/07-sumEven/index.js +++ b/07-sumEven/index.js @@ -1,4 +1,8 @@ export function sumEven(value) { - // implementar logica aqui - + let sum = 0; + for (let i = 0; i < value.length; i++) { + if (value[i] % 2 === 0) { + sum += value[i]; + } + } return sum; } \ No newline at end of file diff --git a/08-isAnagram/index.js b/08-isAnagram/index.js index 918308a..eb064c3 100644 --- a/08-isAnagram/index.js +++ b/08-isAnagram/index.js @@ -1,4 +1,19 @@ export function isAnagram(word1, word2) { - // implementar logica aqui - + let testWord1; + let testWord2; + + if (word1.length !== word2.length) { + return false; + } + + + testWord1 = word1.toLowerCase('').split('').sort().join(''); + testWord2 = word2.toLowerCase('').split('').sort().join(''); + + if (testWord1 === testWord2) { + return true; + } + + return false; + } \ No newline at end of file diff --git a/09-mostRepeatedChar/index.js b/09-mostRepeatedChar/index.js index b113ed8..326b356 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 arrChar; + arrChar = text.split(''); + let countCharMax = 1; + let countChar = 0; + let char; + for (let i=0; i longWord.length){ + longWord = word; + } + } + return words.filter((word) => word.length === longWord.length); } \ No newline at end of file