Seperate key:value object into arrays

Issue

I’m making an ionic project on where I got an incoming array made of key:value object like:

enter image description here

is possible to separate those values in 3 different arrays: date[] speed[] and altitude[]?

Solution

Assuming you have data in this format:

const data = [{a: 10, b: 20, c: 30}, {a: 100, b: 200, c: 300}, {a: 1000, b: 2000, c: 3000}];

const a = data.map((d) => {
 return d.a
});
const b = data.map((d) => {
 return d.b
});
const c = data.map((d) => {
 return d.c
});

Answered By – Ritesh Waghela

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published