Exercise 2: Functional Style Programming

Practice functional-style programming and JavaScript higher-order functions in this exercise.

We'll cover the following

Problem statement

In this exercise, you are required to achieve all the functionality of the code given in the code widget below using functions.

  • The code displays the total sum of double of all the even numbers present in the numbers array.

  • The code consists of if and for statements; your task is to make the code more concise by replacing these statements with functions.

You can see the Arrow Functions and Functional Style lesson for help.

Do-it-yourself challenge

Rewrite the following imperative code to functional style. The solution to this challenge is available in the next lesson, but, try to do it yourself first.

Get hands-on with 1400+ tech skills courses.