Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!