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

140
Vistas
is it possible two make two arrays into one to create an x,y position array?

I am new to this so sorry if the question is dumb I have two arrays, one is an array x values and the other one for y values. I need to make an array that contains both, like [x1,y1,x2,y2...]; how do I make this using loops?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

If both the arrays contain the same number of elements then

let arr = []
let xArr = [/*xValues*/]
let yArr = [/*yValues*/]

for (let i = 0; i < xArr.length; i++) {
    arr.push(xArr[i])
    arr.push(yArr[i])
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

What about objects?

var myObj = {
  x: [
    "1",
    "2"
  ],
  y: [
    "1",
    "2"
  ]
}

You can select it by:

myObj.x[0];
// "1"

myObj.x[1];
// "2"

myObj.y[0];
// "1"

myObj.y[1];
// "2"

Also, we all wonder things as programmers. Your question is not dumb for being curious.

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