teaching machines

CS 347: Lab 15 – Map, Filter, and Reduce

October 15, 2020 by . Filed under fall-2020, labs, webdev.

Welcome to lab. By now you have already watched the lecture videos on your own. Now we will apply the ideas from those videos in an exercise, which you will complete in small groups.

Within your breakout room, designate one of your team to be the screen sharer. Screen sharer, share your screen and claim your group’s task on Crowdsource. Make sure to enter every group member’s JMU eID so that they receive credit. Your group will be assigned a task number.

Team, complete the assigned task below. Screen sharer, be careful not to dominate. All members should contribute ideas.


Screen sharer, follow these steps:

  1. Visit this lab’s repl on repl.it.
  2. Click Fork to make a copy of the repl that you and your team can edit.
  3. In the console on the right, type jest to run the unit tests in lab.test.js. They will all fail.
  4. Click Share and copy the join link to your room’s chat. Apparently you need to sign up for an account before the Share button appears.

All team members should join the repl. Each person needs to make their own account. Click on lab.js, and start writing JavaScript to make the unit tests pass. Each function should be implemented as a single statement in which you call map, filter, or reduce.

Implement the functions outlined in lab.js according to the specifications below. It’s my hope that you can all work simultaneously, but I haven’t tested this.

Screen sharer, when your group is done or when time is up, submit your group’s solution on Crowdsource.

Reference Implementation