Due to the great support from SO users on my initial issue here I could transfer the suggested solution to my certain project environment and could -almost- make it happen.
I have a returned array object resultVolume
with the following structure:
0: {x: "AUDUSD", y: 680, count: 10}
1: {x: "EURCAD", y: 690, count: 9}
2: {x: "USDCAD", y: 250, count: 8}
3: {x: "EURHUF", y: 600, count: 8}
4: {x: "CADCHF", y: 560, count: 7}
5: {x: "AUDNZD", y: 320, count: 7}
6: {x: "AUDCHF", y: 330, count: 7}
7: {x: "EURNOK", y: 590, count: 7}
8: {x: "EURJPY", y: 70, count: 7}
9: {x: "EURAUD", y: 430, count: 6}
10: {x: "EURSGD", y: 50, count: 5}
11: {x: "EURCHF", y: 50, count: 5}
12: {x: "GBPUSD", y: 370, count: 4}
13: {x: "AUDJPY", y: 80, count: 4}
14: {x: "CHFJPY", y: 240, count: 4}
15: {x: "USDJPY", y: 170, count: 4}
16: {x: "SGDJPY", y: 40, count: 4}
17: {x: "AUDCAD", y: 40, count: 4}
I now would like to do both
- cut all objects after the 5th one (so after object number 4) and
- remove the
count
property from all of the objects.
I tried the following:
delete resultCount.count;
const finalResultCount = resultCount.slice(0, 5);
which returns
0: {x: "AUDUSD", y: 680, count: 10}
1: {x: "EURCAD", y: 690, count: 9}
2: {x: "USDCAD", y: 250, count: 8}
3: {x: "EURHUF", y: 600, count: 8}
4: {x: "CADCHF", y: 560, count: 7}
5: {x: "AUDNZD", y: 320, count: 7}
with the count
property not being removed.
Following these solutions I am not sure how to access each object since they all have different numbers in front. So probably I need a loop to achieve the desired outcome?