How To Add A Dot Before Each Item In This List Of Array?
I have an array like this: const array = ['jpg', 'png]. Right now I can join them like this: array.join(',') to produce: jpg,png What the simplest way of getting something like thi
Solution 1:
You can chain .map
and .join
methods:
array.map(function (fileExtension) {
return'.' + fileExtension;
}).join(',');
Fat arrow notation is also acceptable (and short!)
array.map(extension => '.' + extension).join(',');
Post a Comment for "How To Add A Dot Before Each Item In This List Of Array?"