I have an array which contains the contents as follows:
["ZS125-48ATab", "STR125YBTab", "KS125-24Tab", "ZS125-50Tab", "DFE125-8ATab", "ZS125-30Tab", "HT125-8Tab", "HT125-4FTab", "STR50Tab"]
Is it possible to append a #
symbol to the front of each element in the array.
Thanks.
The unshift() method adds new elements to the beginning of an array. The unshift() method overwrites the original array.
By using ArrayList as intermediate storage: Create an ArrayList with the original array, using asList() method. Simply add the required element in the list using add() method. Convert the list to an array using toArray() method.
If you need to add an element to the beginning of your array, try unshift(). And you can add arrays together using concat().
Example for ES6
var arr = ['first', 'second', 'third']; arr = arr.map(i => '#' + i);
Result:
console.log(arr); // ["#first", "#second", "#third"]
for(var i=0;i<array.length;i++){ array[i]="#"+array[i]; }
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