I want to cycle through an array of numbers and if any of those numbers are single digit add a 0 before it, eg 1 becomes 01.
I could do this with a for loop but was wondering if I could use forEach as it seems neater.
Would anyone know if this can be done?
My code so far:
numArr.forEach(function(item) {
if (item < 10) {
item = '0' + item; // How do I update this value in array?
}
});
mapfunction is more appropriate for this.String#padStart.