fix (sum) ajuste

This commit is contained in:
Andresa Rodrigues Figueira Combat 2022-11-02 14:50:03 -03:00
parent 89ab338c36
commit d2f254dd6c
8 changed files with 57 additions and 90 deletions

View File

@ -1,7 +1,7 @@
export function greet(name) {
// function greet(name) {
return'Hello ${name};'
return `Hello ${name}`
}

View File

@ -1,10 +1,3 @@
export function triangleArea(base, height) {
constbase, altura, area;
escreva;('informe a base do triangulo:')
leia;(altura);area:(base, altura)/2
escreva (areadoTriangulosera,area5)
// your code here
export function triangleArea(base, height) {
return base * height / 2
}

View File

@ -1,9 +1,10 @@
export function maxValue(values) {
var arr = [1, 2, 3]; var max = arr. reduce(function(a, b) { return Math. max(a, b); }, -Infinity);
var arr = values;
function getMaxOfArray(numArray) { return Math. max. apply(null, numArray); }
var arr = [50, 10,30, 10]; var max = Math. max(... arr);
}
if (arr.length == 0) return 0;
var max1 = arr.reduce(function (a, b) {
return Math.max(a, b);
}, -Infinity);
return max1;
}

View File

@ -1,22 +1,13 @@
export function fibonacci(value) {
function fibonacci(){
var termo = parseInt(document.getElementById('numero').value);
var resposta = document.getElementById('resposta');
var penultimo=0, ultimo=1;
var numero;
if(termo<=2)
numero = termo-1;
else
for(var count=3 ; count<=termo ; count++){
numero = ultimo + penultimo;
penultimo = ultimo;
ultimo = numero;
}
resposta.innerHTML=numero;
var i;
var fib = [0, 1];
let numero = undefined;
for (i = 2; i <= value; i++) {
fib[i] = fib[i - 2] + fib[i - 1];
numero = fib[i];
}
}
if (numero !== undefined) return numero;
return value;
}

View File

@ -1,18 +1,10 @@
export function isPrime(value) {
function primo(){
var numero = parseInt(document.getElementById('num').value);
var resposta = document.getElementById('resposta');
var divisores=0;
for(var count=1 ; count<=numero ; count++)
if(numero % count == 0)
divisores++;
if(divisores==2)
resposta.innerHTML='É primo';
else
resposta.innerHTML='Não é primo';
}
}
var numero = parseInt(value);
var divisores = 0;
for (var count = 1; count <= numero; count++)
if (numero % count == 0) divisores++;
if (divisores == 2) return true;
else return false;
}

View File

@ -1,12 +1,9 @@
export function sum(values) {
var numbers = [15,40,55];
let sum = 0;
var sum = 0;
values.forEach((element) => {
sum += element;
});
for(var i =0;i<numbers.length;i++){
sum+=numbers[i];
return sum;
}
console.log(sum);
}

View File

@ -1,14 +1,11 @@
export function sumEven(value) {
function retornaNNumerosPares(n) {
let soma = 0;
const numerosPares = value.map((item) => {
if (item % 2 == 0) return item;
});
let numerosPares = [];
for (let i = 0; i < n; i++) {
if (i % 2 == 0) {
numerosPares.push(i)
}
}
return numerosPares;
numerosPares.forEach((num) => {
if (num !== undefined) soma += num;
});
return soma;
}
retornaNNumerosPares(1, 40)
}

View File

@ -1,19 +1,15 @@
export function mostUsedChar(text) {
function mostUsedChar(text) {
nomes = ["fdgdfgf","Lorem ipsum","adsassdasd","testeeeee"];
function retornarLetramaisRepetida(item, indice) {
nomes[indice] = nomes[indice].toUpperCase();
}
nomes.forEach(retornarLetramaisRepetida);
console.log(nomes);
return "e"
}
var getMax = function (str) {
var max = 0,
maxChar = "";
str.split("").forEach(function (char) {
if (str.split(char).length > max) {
max = str.split(char).length;
maxChar = char;
}
});
return maxChar;
};
}
return getMax(text);
}