Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
Udacity: otro tipo de prueba de bucle /JS/Array/.forEach

Soy un principiante de JavaScript. Aprendo el curso en Udacity. Y hay una pregunta simple sobre la práctica de Array, pero no puedo entender por qué. Agradeceré mucho si alguien me puede responder, gracias!

práctica:

  • Cuestionario de programación: otro tipo de bucle (6-8)

  • REQUISITOS DEL EXAMEN

  • Use la variable de test existente y escriba un bucle forEach

  • que suma 100 a cada número que es divisible por 3.

  • Cosas a tener en cuenta:

    • Dentro del ciclo, debe usar una instrucción if para verificar que el código sea divisible por 3
    • Dentro del ciclo, puede actualizar un elemento SOLAMENTE usando arrayName[index]
    • Fuera del ciclo, puede usar console.log para verificar la variable de test */

    prueba var = [12, 929, 11, 3, 199, 1000, 7, 1, 24, 37, 4, 19, 300, 3775, 299, 36, 209, 148, 169, 299, 6, 109, 20, 58, 139, 59, 3, 1, 139];

Responder:

 test.forEach(function (value,index,array){ if (value % 3 ===0){ array[index] +=100; } return value; }); console.log(test);

Mi problema es por qué no puedo usar value +=100 :

 test.forEach(function (value,index,array){ if (value % 3 ===0){ value +=100; } return value; });

¿cual es la diferencia?

Gracias!!!!!!!!1

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!