Write a function square_nums
that takes an array of integers as an argument and
returns a new array with the squares of all of the values of the passed array.
For example, if an array named $arr
stores the values [0, 1, 2, 3, 4, 5]
,
the call square_nums($arr)
should return a new array containing the values
[0, 1, 4, 9, 16, 25]
. If $arr
had instead contained [-1, 4, -5, 25]
,
the call square_nums($arr)
would be expected to return a new array with the values
[1, 16, 25, 625]
.
Constraints:
- Do not modify the passed array.