I want so extract two values from an array holding both of the mentioned values in a single property of an object.
Included you can find my code as well as a Stackblitz project.
I don´t know what to do inside the .map() call in order to split the coords property into two x and y arrays.
Stackblitz: https://stackblitz.com/edit/ckpxyz?file=index.ts
class MyClass {
coords: number[];
constructor(coords: number[]) {
this.coords = coords;
}
}
var myList: MyClass[] = [
new MyClass([1,2]),
new MyClass([3,4]),
new MyClass([5,6]),
new MyClass([7,8]),
new MyClass([9,10]),
]
myList.map((myObj: MyClass) => {
console.log(myObj.coords[0], myObj.coords[1]);
// what to do here to split the array?
});
// GOAL:
// x:number[] = [1,3,5,7,9];
// y:number[] = [2,4,6,8,10];