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

209
Views
Remove single comma from an array in jQuery

I have an array:

let array = ['john,1','mars,2','marry,3','  ,  '];

I want to filter the array in such a way that it should remove extra spaces and only a single comma (without text).

Expected Output:

let array = ['john,1','mars,2','marry,3']

I tried a few methods which removed all the commas.
Please check jsfiddle

Down votes done by those who knows nothing.. :):):)

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

0

array = array.filter(el => {return  el.trim() !== ','})
about 4 years ago · Juan Pablo Isaza Report

0

['john,1','mars,2','marry,3'].map(x=>x.replace(',',''))

result: ['john1', 'mars2', 'marry3']

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!