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

145
Vistas
JavaScript Doing addition and subtraction on specific parts of an array of numbers

I have an array of numbers and I want to subtract 9 from any number larger than 9. I have the code below and it is not giving an error, but it is not doing anything. Tried the .map method and several other ways such as for loops. This has been my first js project so I am not proficient in much. Been stuck on this for a while so I would love to get some help.

evenSum = [4, 4, 0, 12, 0, 10, 2, 8]

evenSum.forEach(evenSums =>{ if(evenSums > 9){ return evenSums - 9 } })

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Use Array.map instead:

evenSum = [4, 4, 0, 12, 0, 10, 2, 8]

let res = evenSum.map(evenSums => evenSums > 9 ? evenSums - 9 : evenSums)

console.log(res)

about 4 years ago · Juan Pablo Isaza 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