I'm trying to implement this code:
const a = [1, 2, 3, 4, 5];
a.multiply();
console.log(a); // [1, 2, 3, 4, 5, 1, 4, 9, 16, 25]
The result array needs to be concatenated at the end of the original array. I'm using the following code but it returns only the array with the values multiplied:
Array.prototype.multiply = function() {
return this.map(function(item){return item * item})
}
a.multiply();
console.log(a); //[1, 4, 9, 16, 25]
Can anyone help me please?