Arrow Addition Puzzle Explainer

#1

Aim of the puzzle:
This puzzle is a review of arrow functions. You’ll create an arrow function that takes two numbers and returns their sum.

Walk through of the Solution:
An arrow function is a compact way to create a new function. It uses let ___ () => {} instead of function ___ () {}.

In the code that you start off with, there is an arrow function, sum, two variable declarations, num1 and num2, and a console.log(). As it is, the sum function is incomplete. In this puzzle, you’ll complete it by updating the return statement.

To complete the puzzle, update the return statement to x + y. Now, when the code runs, the sum function will return the value of num1 plus num2.

Sample code solution:

let sum = (x, y) => {
    return x + y
}

let num1 = pickRandom(10)
let num2 = pickRandom(10)

console.log('The sum of ' + num1 + ' and ' + num2 + ' is ' + sum(num1,num2))   

Javascript Concepts: Arrow Functions, Functions, Let, Variable, Return Statement, console.log()
Grasshopper Concepts: pickRandom()

listed #2