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

114
Visualizações
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 Respostas
Responde à pergunta

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 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