function squareNums(arr) {
const newArray = []
for (let i = 0; i < arr.length; i++){
newArray.push(arr[i] * arr[i]);
}
return newArray
}
console.log(squareNums([2,4,6,8,10]));
Created
June 17, 2021 05:07
-
-
Save tripdog/680ef04c3c4da984adc76fa094ffdf95 to your computer and use it in GitHub Desktop.
Create a function that returns the square of each number in an array.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment