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

172
Vistas
How to map in "old JS" ECMAScript 5?

I have 4 strings that I would like to separate them with ECMAScript 5 and create a new object with each first element together.

Exemple: Each first element of the array stay in a new variable containing the first element of the first element of the second array and the first element of the last array. Of course I had to separate {PANTONE...} from yellow (they are in the same array) and I create a new array and pushed the color "yellow to it". After I separate the firsts with the seconds, etc, I map them into a new variable

I did with modern JS but I have no clue howe can I do it with "old" JS:

var name = ["{PANTONE Yellow C}  {PANTONE 364 C} {PANTONE 137 U} magenta black {PANTONE Reflex Blue C} cyan"]

var percentage = ["0.546829 6.88961 1.03087 0.135706 10.2713 1.98788 0.508267 17.6122"]

var surface = ["1033.87 13025.6 1948.99 256.568 19419 3758.33 960.938 33297.9"]

I want to map it like this:

var result = 
{{PANTONE Yellow C}, yellow, 0.546829, 1033.87},
{{PANTONE 364 C}, "no color", 6.88961,6.88961},
{{PANTONE 137 U}, magenta, 1.03087, 1948.99}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you have to use explode the string by space, in more complex situation you should use regular expression for string to array conversion. first of all you have to convert strings into array and then you can create object of that data or you can print as you want.

let str = "0.546829 6.88961 1.03087 0.135706 10.2713 1.98788 0.508267 17.6122";
const arrayExploded = str.split(" ");
arrayExploded[0] //will get 0.546829 

now you can use map or any loop function to get all the array data

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