Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
Verify if this line of codes are correct
function sumOfNumbers(arrayOfNumbers) {
  let arrayOfNumbers = [1, 2, 3, 4, 5, 6, 7]
  const arrayLength = arrayOfNumbers.length;
  let sum = 0;
  for (i = 0; i <= arrayLength; i++) {
    sum = sum + arrayLength[i];
  }
  /*console.log(sumOfNumbers(sum))*/
  return (sumOfNumbers(sum));
}

I used console.log nothing came up, I will appreciate if I am corrected.

about 4 years ago · Santiago Gelvez
3 Respostas
Responde à pergunta

0

if the function is correct

 function sumOfNumbers(arrayOfNumbers) { let arrayOfNumbers = [1, 2, 3, 4, 5, 6, 7] }

the function returns the sum of the values of the array or vector

 return (sumOfNumbers(sum));

about 4 years ago · Santiago Gelvez Relatório

0

about 4 years ago · Santiago Gelvez Relatório

0

You have many mistakes in your code. Added comments in the code below to say what you did wrong and what you need to actually do.

function sumOfNumbers(arrayOfNumbers) {
  const arrayLength = arrayOfNumbers.length;
  let sum = 0;
  // you need to declare i so it is not a global
  // Indexes start at ZERO so the <= arrayLength would cause you to reference one past the length of the array
  for (let i = 0; i < arrayLength; i++) {
    // you are trying to read arrayOfNumbers... wrong, needs to be the array
    sum = sum + arrayOfNumbers[i];
  }
  // return the sum
  return sum;
}

// define your array of numbers outside
const myNumbers = [1, 2, 3, 4, 5, 6, 7];
// call the method passing in the array
console.log(sumOfNumbers(myNumbers));

about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda