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

100
Views
Add single quotes in a string array javascript

I been searching for the solution but can't find it...

I have the following array with the following output:

['Fruits, Cars, Clothes, Shoes']

But I need the that array to output the following:

['Fruits', 'Cars', 'Clothes', 'Shoes']

I already tried the following and it did not work:

var output= arr.map(item => "'" + item + "'").join();

Can you help please

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

0

Just get the first (and unique) item of your array, then split it and trim every element:

const arr = ['Fruits, Cars, Clothes, Shoes'];

const newArr = arr[0].split(',').map(x => x.trim());

console.log(newArr);

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!