For example, you can reduce an array [5,4,3,2,1] into the value 15 by just adding them.
Reduce function keeps developers away from using loop in order to fold a list into a single value.
In this blog, you will learn ways to implement well-known functions using reduce as already done by developers in top software development company
array (to transform list of items), transform Function (is a function used to run on each element)
By using the given transformFunction, each element in the given array get transformed and returns new array of items.
How to implement?
const map = (transformFunction, array1) =>
array1.reduce((newArray1, xyz) =>
const double = (x) => x * 2;
const reverseString = (string) =>
map(double, [200, 300, 400]);
Output: [400, 600, 800]
map(reverseString, ['Hello Alka', 'I love cooking']);
// ['alkA olleH', ‘gnikooc evol I']