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

280
Views
Convert to string without removing whitespace after every comma

I have one requirement which needs my string to allow whitespace after every comma.My Array looks like this ['yes', 'no']. While converting this to string it became in the order of yes,no but I want the output to be like this yes, no allowing whitespaces after every comma.

let array=['yes', 'no'];
let result = array.toString().substring(0, (array.toString()).length).split(",");
console.log(result);

Answer was like yes,no but I need it to be yes, no. Is the any way by which I can get this output as a result.

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

0

let array=['yes', 'no'];
console.log(array.join(', '))

about 4 years ago · Juan Pablo Isaza Report

0

Try

    let array=['yes', 'no'];
    let result = array.toString().substring(0, (array.toString()).length).split(",").join(', ');
    console.log(result);
about 4 years ago · Juan Pablo Isaza Report

0

let array=['yes', 'no'];
let result = array.join(', ');
console.log(result); // Outputs - "yes, no"
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!