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

111
Views
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 answers
Answer question

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