I'm experimenting with functions. I know nested functions are possible, but seeing if someone could help with syntax errors
CHALLENGE: Create a function that takes a number, and creates an array from every number up to that number. But return the square of each number as an array, then sum them up. Return the sum.
function squaredSum(number) {
var squaredNumberArray = []
for (var i = number; i > 0; i--) {
squaredNumberArray.push(i**2)
} var sum = function(squaredNumberArray) {
var summation = 0
for (var x = 0; x < squaredNumberArray.length; x++) {
summation = summation + squaredNumberArray[x];
}
} return summation;
}
console.log(summation);