Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

0

about 4 years ago · Santiago Gelvez Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda