Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading