JavaScript Higher-Order Functions

Due: 11:00pm, Monday February 22, 2021

Max grace days: 2

Description

The goal for this assignment is to use higher-order functions in JavaScript to process data about Pokemon. The original source of the data for this assignment is here pokemon.json. The data is an array of objects where each object has the following structure:

This assignment contains the following files: index.html, data.js, code.js, and reference.html. You only need to edit the code.js file. You must write five functions where each function has a similar form: take the data (an Array of Pokemon objects) as a parameter and return an Array of Pokemon objects. Descriptions of the functions are as follows:

  1. Return an array of the five Pokemon objects that have the highest “HP” values. The result must be ordered from highest to lowest “HP” value.
  2. Return an array of all the Pokemon objects that have the lowest “Sp. Attack” values. The result must be ordered in alphabetic order of English name.
  3. Return an array of Pokemon objects that have both “Grass” and “Poison” in the “type” property. The result must be ordered from lowest to highest “Attack” value.
  4. Return an array of Pokemon objects that have “Rock” in the “type” property and also have a “Speed” value higher than the average “Speed” value of Pokemon that have “Electric” in the “type” property. The result must be ordered from highest to lowest “Speed” value.
  5. Return an array of Pokemon objects where each Pokemon object has an “Attack” value that is at least three times greater than its “Defense” value. The result must be ordered from highest to lowest “Attack” value.

You must also write a “main” function that calls each above function in turn and outputs the results as shown in the reference.html file. You may also write additional helper functions if you choose to.

All functions in this assignment must satisfy the following criteria:

Turning in the Assignment

For this assignment, you must turn in a zip file containing the following file:

  1. code.js

Submit the zip file to the appropriate folder on D2L.

Grading Criteria

Grading (out of 100 points):