feat(all-script)otimiza o codigo

This commit is contained in:
Henrique Martins Silva 2022-10-31 07:51:30 -03:00
parent 3d6b9dea46
commit edd318c580
8 changed files with 54 additions and 52 deletions

View File

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

View File

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

View File

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

View File

@ -1,8 +1,8 @@
export function fibonacci(value) {
// implementar logica aqui
if (value === 0 || value === 1){
return value
}else{
return fibonacci(value - 1) + fibonacci(value - 2)
}
}
if (value === 0 || value === 1) {
return value;
} else {
return fibonacci(value - 1) + fibonacci(value - 2);
}
}

View File

@ -1,12 +1,12 @@
export function isPrime(value) {
// implementar logica aqui
let primo = true
for(let i = 2; i < value; i++){
if(value % i === 0){
primo = false
break
}
}
let primo = true;
for (let i = 2; i < value; i++) {
if (value % i === 0) {
primo = false;
break;
}
}
return primo
}
return primo;
}

View File

@ -1,8 +1,8 @@
export function sum(values) {
// implementar logica aqui
let soma = 0
for (let i = 0; i < values.length; i++){
soma += values[i]
let soma = 0;
for (let i = 0; i < values.length; i++) {
soma += values[i];
}
return soma
return soma;
}

View File

@ -1,10 +1,10 @@
export function sumEven(value) {
// implementar logica aqui
let soma = 0;
for(let i = 0; i < value.length; i++){
if(value[i] % 2 === 0){
soma += value[i];
}
for (let i = 0; i < value.length; i++) {
if (value[i] % 2 === 0) {
soma += value[i];
}
}
return soma;
}
}

View File

@ -1,21 +1,23 @@
export function mostUsedChar(text) {
// implementar logica aqui
let cont=0, maior=0
// implementar logica aqui
let cont = 0,
maior = 0;
let resp = text.toLowerCase()
let resp = text.toLowerCase();
let i = 0, j = 0
for(i = 0; i < text.length; i++){
cont = 0
for(j = 0; j < text.length; j++){
if(resp[i] == text[j]){
cont++
}
}
if(maior < cont){
maior = cont
var resposta = resp[i]
}
}
return resposta
}
let i = 0,
j = 0;
for (i = 0; i < text.length; i++) {
cont = 0;
for (j = 0; j < text.length; j++) {
if (resp[i] == text[j]) {
cont++;
}
}
if (maior < cont) {
maior = cont;
var resposta = resp[i];
}
}
return resposta;
}