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) {
// implementar logica aqui
return `Hello ${name}`
return `Hello ${name}`;
}

View File

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

View File

@ -1,10 +1,7 @@
export function maxValue(values) {
// implementar logica aqui
if (values.length === 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) {
// 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
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
return fibN;
}

View File

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

View File

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

View File

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

View File

@ -1,6 +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
}
word2 = word2.toUpperCase().split('').sort().join('');
return word1 === word2;
}

View File

@ -1,19 +1,18 @@
export function mostUsedChar(text) {
// implementar logica aqui
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;
}
let mostUsedCount = 0;
for (const letter of text) {
let countLetter = 0;
for (const letterToCount of text) {
if (letterToCount === letter) {
countLetter++;
}
return result;
}
if (countLetter > mostUsedCount) {
mostUsedCount = countLetter;
result = letter;
}
}
return result;
}

View File

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