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

129
Views
build array of json object while looping array of data

I have an array const A=['string1','string2','string3'].

I want to achieve an object that has the following form:

const images = [
  { url: "string1" },
  { url: "string2" },
  { url: "string3" }
];

This is what I've tried:

const images = A.map((image) => {
  JSON.stringify({
    url: `/img/{image}`
  });
});

But the result is an array filled with undefined values.

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

0

I do not understand why are you using JSON.stringify()?

The simplest solution:

const images = A.map((image) => ({
  url: `/img/${image}`
}))

The () that are wrapping the implicit return are mandatory since we're directly returning an object.

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!