Iteration in TypeScript
Objectives
- After completing this assignment, you should be able to:
- Demonstrate understanding of iteration/enumeration
Instructions
- Fork this repository to your own account.
- Change into your projects directory:
- Clone your repository:
hub clone ts-iteration
- Change into your project's directory:
cd ts-iteration
- Install the dependencies:
npm install
- Open in your editor:
code .
- Start the test runner:
npm start
- In VS Code, open the file:
src/functions.ts
and work on functions until tests pass. - Commit and push your work to GitHub.
Explorer Mode
- As you write each function and make them pass the
npm start
screen will show your progress. - Work until all the tests are passing
Epic Mode
Using the
forEach
looping method and no other looping or enumeration helper, write your own version of the following methods, except name yours_map
,_filter
, etc.- Your method must accept an array and a callback function.
- Example for your
_map
:
const numbers = [1, 2, 3, 4, 5]const doubled = _map(numbers, function (number) {return number * 2})// doubled needs to be [2,4,6,8,10]const increased = _map(numbers, function (number) {return number + 2})// increased needs to be [2,3,4,5,6]map
filter
reduce
every
some
Write some example usage of your new methods to demonstrate that they work
Additional Resources
Reference the documentation on DevDocs to find what kind of helpful functions might already be in TypeScript.