From the course: Learning Functional Programming with JavaScript ES6+
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Recreate the map function - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
Challenge: Recreate the map function
(upbeat music) - [Instructor] Now that we've had a lot of practice with JavaScript's functional parts such as built in array functions, let's do a challenge. The challenge here, to make sure you really understand how the map function works, is to recreate the map function. Specifically, what we want to create is a function called map that takes two arguments. The first argument is an array and the second argument is a function that should be applied to every element in the array. Your task is to recreate the map function in this way, obviously without using JavaScript's built in map function. There are quite a few different solutions to this problem but one of the easier solutions is to use a for Loop and one of the harder versions is to use only JavaScript's built in reduce function. You'll want to write your code inside the body of this map function here and if you've implemented it correctly, when you run your code, these lines here should print the correct answers to the console…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
JavaScript: Functional parts1m 53s
-
(Locked)
The spread operator5m 30s
-
Mapping5m 11s
-
(Locked)
Filtering6m 59s
-
(Locked)
Every/some5m 46s
-
(Locked)
Slicing3m 38s
-
(Locked)
Sorting5m 11s
-
(Locked)
Reducing6m 23s
-
(Locked)
Combining functions6m 40s
-
(Locked)
Challenge: Recreate the map function1m 3s
-
(Locked)
Solution: Recreate the map function3m 6s
-
(Locked)
-
-
-