How to add prefix to array values?

Array.prototype.map is a great tool for this kind of things:

arr.map(function(el) { 
  return 'images/' + el; 
})

In ES2015+:

arr.map(el => 'images/' + el)

Leave a Comment