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

237
Views
Multiple arrays inside a array in javascript

when i do console.log(myArray) I obtain this:

console.log result

I want to take a value inside only one of this arrays, but how? When i do console.log(array[0]) I obtain this result:

37.7
28.45
36.38
about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You have nested arrays. So your main array has three elements each of which contains one number, and the indexes of those arrays go from 0 to 2.

You access each nested array with its index, and then access the number with the 0 index (because there's only one element in that nested array).

const arr = [[37.7], [28.45], [36.38]];

console.log(arr[0][0]);
console.log(arr[1][0]);
console.log(arr[2][0]);

Or even loop over the array and destructure the number from each nested array:

const arr = [[37.7], [28.45], [36.38]];

for (let [number] of arr) {
  console.log(number);
}

about 4 years ago · Juan Pablo Isaza Report

0

Please compare your code with this working example:

let myArray = [37.7, 28.45, 36.38];
console.log(myArray[0]); // outputs 37.7
about 4 years ago · Juan Pablo Isaza Report

0

From what I can see in the original question so far, the output of this function is actually three different console.log() executions, which leads me to believe that whatever is firing these console.logs is actually running in some sort of loop.

If that is the case, you will not be able to pull just one value out to simply. The screenshot you added only shows the output. Could you please add the code for (or screenshot of) all the related code from setting up or fetching the array, to your console.log? With all that context, I can rewrite my answer to get you the exact answer you are looking for.

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!