Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

157
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda