Due: Thursday, Dec. 17 by 1:30pm (Start of Final Exam)
In order to visualize your data, the JavaScript program needs to know about some of the features of your data. You will be writing three small JavaScript functions that will return information about your data.
In order to turn your data into a plot, we need to define the boundaries of
the plot. To do that, you will complete the functions findBestScore
and findWorstScore
that will find the best and worst scores
from your data set.
Before starting to program, you will want to check what the best score looks like in your data. If your event is a time-scored event, such as a race, the best score will be the lowest score (eg: fastest time). If your event is a score-based event, the best score will be the highest score (eg: best performance).
Both of the functions receive exactly one function argument,
data
, which will contain data of the format described in
Part 1. To complete this MP, you must write these functions to find
the best and worst scores (eg: you cannot simply return the value that
is the minimum in your data set).
You should complete these functions in mpx.js in the area marked as Part 2.
In Part 2.1, you completed the functions to describe the x-axis. In this
part, you will complete the findUniqueYears
function.
The findUniqueYears
takes the same input, data
,
but must return an array of the unique years from your data set. For example,
if your data contains the years 2012, 2008, and 2004, your function must
return an array: [2012, 2008, 2004]
.
There are several ways to complete this function. Using only what you already know,
this can be done with two for-loops (one inside of the other). However, you may
find the indexOf
method of an array useful. (Note that indexOf
returns -1 when an element is not found in the array.)
You should complete these functions in mpx.js in the area marked as Part 2.
As part of this MP, a test suite is provided for you to help you understand what part of the MP is currently not working. Once you have completed Part 1, open tester.html in a web browser and ensure that all of the tests listed in "Overall", "Part 1", and "Part 2" are complete!