Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda