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

156
Views
Typescript map utilisation

this is the data that I have :

enter image description here

and I've created 4 arrays respectevly

   public underlyingsFirstRow = [{perf:0,color:''}];
    public underlyingsSecRow = [{ perf: 0, color: '' }];
    public underlyingsThirdRow = [{ perf: 0, color: '' }];
    public underlyingsFourthRow = [{ perf: 0, color: '' }];

I want the underLyingsFirstRow to contain the first element of each of the arrays
ex [1.09,1.44,0.72,0.98,....,1.22]
and for the underlyingsSecRow [0.96,1.40,0,0.93,0,0.99,...,1.09]
since the third and fifth and the seventeenth data row has only one element and it's 0.72
I want the underlyingsSecRow to have a value of 0 indicating that there is no value there so I can use it to display some points in a graph and I want to do the same for the remaining array that I've created
this is what've wrote

this.underlyingsFirstRow.shift();
        this.underlyingsSecRow.shift();
        this.underlyingsThirdRow.shift();
        this.underlyingsFourthRow.shift();
        this.products.map(p => p.Underlyings.map((u, index,array) => {
            if (index == 0) {
                this.underlyingsFirstRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf });

            } else if (index == 1) {
                console.log()
                if (p.Underlyings.length > 1)
                    this.underlyingsSecRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf });
                else {
                    this.underlyingsSecRow.push({ perf: 0, color:'white' });

                }
 
            }
            else if (index == 2) {
                this.underlyingsThirdRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf });
            }
            else if (index == 3) {
                this.underlyingsFourthRow.push({ perf: (Number((u.perf100 * 100).toFixed(2))), color: u.colorPerf });
            }
        }));

for the first array it worked since they all have at least one element enter image description here


but for the others it didn't work and the length of the array got reduced ex this is underlyingsSecRow

enter image description here

is there a way to get the desired data ?

about 4 years ago · Juan Pablo Isaza
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!