...

/

Solution Review: Functional Style Programming

Solution Review: Functional Style Programming

Take a look at the solution to the challenge given in the "Functional Style Programming" lesson.

Solution

The solution to the previous challenge is given below. Let’s explore it.

Press + to interact
'use strict';
const numbers = [1, 5, 2, 6, 8, 3, 4, 9, 7, 6];
console.log(
numbers.filter(e => e % 2 === 0)
.map(e => e * 2)
.reduce((total, e) => total + e));

Explanation

What are we doing here? We have an array of numbers, and we are trying to get the total sum of double of all the even numbers present in that array. So, functionality consists of three steps.

...