Used .map to modify input array instead of using a separate output array

[#59020952]