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

181
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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