I was trying to create a prototype on Array to return the array with each element uppercased. I was trying to think of an efficient way of handling it but couldn't think of anything that didn't involved iterating through it and placing them in a temp array, which I then return.
Array.prototype.toUpperCase = function() {
let array = this;
let temp = [];
array.forEach(x => {
temp.push(x.toUpperCase());
})
return temp;
}
Is there a more efficient way, without iterating over the array?