In the iterators lab we will be continuing our exploration of iterators and building a few more useful methods. These methods will belong to an Iterators namespace, which we discussed in class. We also will try to use various testing methods to verify that our code is working.
Research the following term and summarize your findings on it two to three sentences:
higher-order function
Pretending we implemented the following methods, update this README with a description of each of the following and an example you've created:
Use the notes provided to help guide you explanation.
-
Write a test in the
test
folder formin
and implement it in thesrc/iterators.js
folder. There is a test for amax
method already if you'd like to use that as inspiration. -
Re-implement the
each
function we did in class, but write the spec for it first. Continue this exercise withmap
andfilter
.
Implement the remaining iterator methods in the namespace.
Refactor the following code using map
to make only one call to the map
function versus the two below.
var myNumbers = [ -1, 2, -3, 4, -5, 6];
var square = function(num) {
return num * num;
};
var sqrRoot = function(num) {
return Math.sqrt(num);
};
var sqrNumbers = map(myNumbers, square);
var absNumbers = map(sqrNumbers, sqrRoot);