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

113
Vistas
multiply the values of a ton of arrays then put it back in origianl form

I am trying to make a chart that gets data from an API endpoint with open, close, high, and low data for a bar chart like the ones you see for stocks. I make the endpoint request, and use .map to reach for example the value for low.

The issue is that the result needs to be multiplied by 213 before being displayed on the chart, how can I write a code that takes the value of every single one of these arrays, multiplies the inner value by 213, and puts it back in the original form so the chart can use it?

code used to reach the data:

const usdlow =response2.data.data.ethereum.Trades.map(el => ({low: el.low}))

*example

console.log(usdopen[1])

result:

{open: 6.606731585128299}

There are about 5000 arrays for different points.

I basically want to get this open value out, multiply it by 213, and then put it back in so the chart can take it and use it.

I have not been able to get this to go back to the original form so chart can use it, I believe the method I use doesn't work for arrays like this. I would appreciate any help, thanks for your time.

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

0

Actually, it's easy. If you have an array of objects, you can just use the spread operator to spread the rest of the object and multiply the values you'd like to change by 213:

let arr = [
    { key: 1, value: 10 },
    { key: 2, value: 103 },
    { key: 3, value: 45 },
    { key: 4, value: 89 },
];

arr = arr.map((item) => {
    return { ...item, value: item.value * 213 };
});

console.log(arr);

// expected output: [ { key: 1, value: 2130 }, { key: 2, value: 21939 }, { key: 3, value: 9585 }, { key: 4, value: 18957 } ]

Et voilà... values changed. 🤓

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