style(desafios):ajustes-de-formatação

This commit is contained in:
Nicolas Oliveira 2022-10-29 17:26:12 -03:00
parent 61d109746a
commit ed3dc03c5f
10 changed files with 49 additions and 58 deletions

View File

@ -1,4 +1,4 @@
export function greet(name) { export function greet(name) {
// implementar logica aqui // implementar logica aqui
return `Hello ${name}` return `Hello ${name}`;
} }

View File

@ -1,5 +1,5 @@
export function triangleArea(base, height) { export function triangleArea(base, height) {
// your code here // your code here
let area = base * height / 2 let area = base * height / 2;
return area return area;
} }

View File

@ -1,10 +1,7 @@
export function maxValue(values) { export function maxValue(values) {
// implementar logica aqui // implementar logica aqui
if (values.length === 0) { if (values.length === 0) {
return 0; return 0;
} }
return Math.max.apply(null, values);
return Math.max.apply(null,values);
} }

View File

@ -1,14 +1,14 @@
export function fibonacci(value) { export function fibonacci(value) {
// implementar logica aqui // implementar logica aqui
if (value < 1) return 0 if (value < 1) return 0;
if (value <= 2) return 1 if (value <= 2) return 1;
let fibMinus2 = 0 let fibMinus2 = 0;
let fibMinus1 = 1 let fibMinus1 = 1;
let fibN = value let fibN = value;
for (let i = 2; i <=value; i++){ for (let i = 2; i <= value; i++) {
fibN = fibMinus1 + fibMinus2 fibN = fibMinus1 + fibMinus2;
fibMinus2 = fibMinus1 fibMinus2 = fibMinus1;
fibMinus1 = fibN fibMinus1 = fibN;
} }
return fibN return fibN;
} }

View File

@ -1,13 +1,12 @@
export function isPrime(value) { export function isPrime(value) {
// implementar logica aqui // implementar logica aqui
if(value == 0 || value == 1) { if (value == 0 || value == 1) {
return false return false;
}
for(let div = 2; div <= Math.sqrt(value); div++){
if(value % div == 0) {
return false
} }
} for (let div = 2; div <= Math.sqrt(value); div++) {
return true if (value % div == 0) {
return false;
}
}
return true;
} }

View File

@ -1,13 +1,10 @@
export function sum(values) { export function sum(values) {
// implementar logica aqui // implementar logica aqui
if (values.length === 0) { if (values.length === 0) {
return 0; return 0;
} }
let sum = values.reduce(function (accumulator, value) {
let sum = values.reduce(function(accumulator,value){
return accumulator + value; return accumulator + value;
}) })
return sum;
return sum
} }

View File

@ -3,7 +3,6 @@ export function sumEven(value) {
const newArray = value; const newArray = value;
var i; var i;
let total = 0; let total = 0;
for (i = 0; i < newArray.length; i++) { for (i = 0; i < newArray.length; i++) {
if (newArray[i] % 2 === 0) { if (newArray[i] % 2 === 0) {
total = total + newArray[i]; total = total + newArray[i];

View File

@ -2,5 +2,5 @@ export function isAnagram(word1, word2) {
// implementar logica aqui // implementar logica aqui
word1 = word1.toUpperCase().split('').sort().join(''); word1 = word1.toUpperCase().split('').sort().join('');
word2 = word2.toUpperCase().split('').sort().join(''); word2 = word2.toUpperCase().split('').sort().join('');
return word1 === word2 return word1 === word2;
} }

View File

@ -14,6 +14,5 @@ export function mostUsedChar(text) {
result = letter; result = letter;
} }
} }
return result; return result;
} }

View File

@ -2,8 +2,8 @@ export function longestWords(words) {
// implementar logica aqui // implementar logica aqui
let newArr = []; let newArr = [];
let long = 0; let long = 0;
words.forEach(function(element){ words.forEach(function (element) {
if(element.length > long){ if (element.length > long) {
long = element.length long = element.length
} }
}); });