Chartjs-How to iterate over array elements inside objects in javascript

1👍

Say response is the response you have, which contains c with n elements and t with n elements too.

To get the result you want, you can do:

const data = response.t.reduce((acc, curr, i) => {
  acc.push({
    x: response.c[i],
    y: curr,
  });
  return acc;
}, []);

Leave a comment