I have a list of allowed file extensions that can be uploaded to my site.
I check them with jQuery Validation plugin.
I'm displaying an error message if they choose a non supported extension.
It looks like
var msg = 'You may only upload files of type ' + allowedExt.join(', ');
Obviously the list doesn't look too flash. I'd like it to look more human readable.
Any way to do this?
A simpler way to do the answer posted by alex is by using .pop()
to get the last element off:
var niceList = function(array, join, finalJoin) {
var arr = array.slice(0), last = arr.pop();
join = join || ', ';
finalJoin = finalJoin || ' and ';
return arr.join(join) + finalJoin + last;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With