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

124
Views
Converting Array stored as a String to a List object in JavaString

I have the following list:

nested_list = [
  ["[63]"],
  ["[61]"],
  ["[7]"],
  ["[63]"],
  ["[80, 18]"],
  ["[80, 43, 18, 20]"]
]

Which is a mess I know, but this is the data that I have to deal with at the moment and I need it to be like this:

[63, 61, 7, 63, 80, 18, 80, 43, 18, 20]

So basically converting it into a list of numbers. Is this doable using as minimum loops as possible?

I have used flat() nested_list .flat(2) and ended up with the following result:

[ '[63]', '[61]', '[7]', '[63]', '[80, 18]', '[80, 43, 18, 20]' ]

Also tried reduce + concat following this but since it is a string, it is not working and I'm not sure where to go from here.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.flatMap() + JSON.parse() can do this quite easily

const nested_list = [
  ["[63]"],
  ["[61]"],
  ["[7]"],
  ["[63]"],
  ["[80, 18]"],
  ["[80, 43, 18, 20]"]
];

const result = nested_list.flatMap(JSON.parse);

console.log(result)

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!