Inside Output explainer

Aim of the puzzle: Declare a variable to use locally inside a function
Walk through of solution:
In some functions, it is necessary to declare a variable to store a value, and then return that variable at the end of the function.

In this puzzle, the sum() function will take an array of numbers, and return the sum of those numbers.

Inside the function, declare a variable to store the sum. Set its value to 0 to start.

Then, add a for loop to iterate through the array, and inside the code block, use the += operator to add each number in the array to the local variable.

At the end of the function, below the for loop, return the local variable.
Sample code solution:

let numbers = [2,3,5];
function sum(numberArray) {
    let sum = 0;
    for (let num of numberArray) {
        sum += num;
    }
    return sum;
}

console.log(sum(numbers));

Javascript Concepts: Variables, Functions, Output, For Loops, += Operator, Return Statements