Arrow Dynamics Explainer

#1

Aim of the puzzle: Use an arrow function
Walk through of solution: An arrow function is like a regular function, except with a different syntax. They are a useful way to quickly write a function using less code than one would with the function keyword. This is why they are often used for callback functions.

In this puzzle, the getAverage function takes a parameter called numbers. It declares a local variable called sum and sets its value to 0.

The for loop iterates through the array of numbers, and adds each number to sum. After the for loop finishes, the last line of the function returns sum / numbers.length.

To complete the puzzle, add sum += number to the code block of the for loop. Then, change the return statement to return sum / numbers.length.
Sample code solution:

let numberList = [15, 20, 13, 47];

let getAverage = (numbers) => {
    let sum = 0;
    for (let number of numbers) {
        sum += number;
    }
    return sum / numbers.length;
};

console.log(getAverage(numberList));

Javascript Concepts: Functions, Arrow Functions, Arrays, For Loops, Output Variables, console.log, Return Statements