The missing space is due to the way you are joining the data. It concatenates the array elements with the specified separator, but it doesn't add spaces automatically after the comma. You should use -
let data = ["apple", ["banana", "cherry"], "date"];
let result = data.map(item => Array.isArray(item) ? item.join(", ") : item).join(", ");
console.log(result);
The output will be -
"apple, banana, cherry, date"
a Working fiddle -
Correct Joining Method[
^]