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.
>Solution :
let array=['yes', 'no'];
console.log(array.join(', '))