Adding text to beginning of each array element
Solution 1:
Example for ES6
var arr = ['first', 'second', 'third'];
arr = arr.map(i => '#' + i);
Result:
console.log(arr); // ["#first", "#second", "#third"]
Solution 2:
for(var i=0;i<array.length;i++){
array[i]="#"+array[i];
}
Solution 3:
Iterate over the array and just add #
var arr = [your array];
for (var i=arr.length; i--;) {
arr[i] = '#' + arr[i];
}
FIDDLE
In newer browsers you could do
arr = arr.map(function(e) {return '#' + e});
Solution 4:
Simple & sweet in ES6 as,
array.map((line) => `#${line}`);