Skip to content

Hw1

Possible Points Due Date
50 pts February 7th - Before Class

Overview

In this homework assignment, you will download a JSON dataset from the web and write a simple data analytics package in JavaScript to answer eight questions about your dataset.

Assignment Instructions

Step 1: Download a JSON dataset from a website

In this step, you will collect a JSON dataset containing at least 100 rows (i.e., entries) from a website. You are free to choose whatever data source you’d like. Note that some, but not all, data sources may first require you to obtain an API key by creating an account with the data provider. You should not choose any API that requires you to authenticate using oAuth, as we have not yet covered oAuth.

You may, but are not required to, choose a data set from one of the following:

After choosing an API, you should collect a dataset containing at least 100 records in JSON format. It’s fine if your dataset contains more than 100 records. If you dataset is very large (> 10,000 records), you may wish to choose a subset of the dataset to enable you to test your code more quickly in the following steps.

Step 2: List eight (8) questions you will answer about your dataset

Now that you’ve found a dataset, what insights can you extract from this dataset? In this step, you will write a list of eight (8) questions about your dataset. Each question should describe a statistic to compute from your dataset.

For example, if your dataset is city demographic data, you might have the following questions:

  1. What is the average age of residents?
  2. What is the average year over year growth rate?
  3. What is the fastest growing city?
  4. What is the median population density?
  5. What is the city with the highest population density?
  6. Which is the average age of small cities with less than 100,000 people?
  7. What is the city with the oldest population?
  8. What is the city with the least amount of new home construction per capita?

In order to more easily satisfy the requirements of step 3, you are encouraged to have a diversity of question types.

Step 3: Implement a JavaScript program to answer your questions

In this step, you will now create a JavaScript program to compute the answers to your eight questions using your JSON dataset. For each of the eight questions, your program should output to the JavaScript console (1) the question and (2) the answer. For example, if your question was “What is the fastest growing city?”, your program should write to the console: “What is the fastest growing city? Springfield”

Your program must use all of the following JavaScript features:

  • Variable declarations

    • Let statement
    • Const statement
  • Functions

    • Arrow function
    • Default values
    • Array.map()
  • Loops

    • For of statement
    • For in statement
  • Collections

    • Instance of a Map or Set collection (only 1 is required)
  • Strings

    • Template literal
  • Classes

    • Class declaration
    • Constructor
    • Using an instance variable with this

You are welcome and encouraged to consult any publicly available resource you wish (e.g., Mozilla Developer Network documentation, tutorials, blog posts, StackOverflow). However, in this assignment, all of the code you submit should be your own.

Submission instructions

  • Submit your HW through replit. Please follow these instructions for signing up for the replit account and accessing HW1. You should be able to complete this project using only the replit web interface. However, if you would like to work locally on your machine, you can code using your preferred environment and then upload the final .js files through replit.

The HW assignment submission should consist of two .js files one called data.js containing the following:

  1. A comment containing a URL where your JSON dataset from step (1) can be found
  2. Your JSON dataset from step (1) (or a subset of the dataset that is at least 100 records)

and another call index.js containing the following:

  1. A comment with your full name and G-number
  2. The questions for your program from step (2)
  3. Your program from step (3)

Grading Rubric

The grading for this project will be broken down as follows:

  • 8 Valid Questions about Dataset - 1 point each (8 points total) - We will take into account whether or not the question can be answered programmatically using your dataset.
  • Valid JSON Data - 6 points, your JSON data must have at least 100 entries and must have enough attributes to be able to form 8 meaningful questions to answer.
  • Javascript Features - 3 points each (36 points total) - You must use each requested feature and each feature must be used in the calculation of the answer of at least one of your questions.

Note

Please note that we will not be grading you for code comment or structure in this assignment. However, we will be giving you comments on this. For future assignments, this will be worth 10 points. So practicing by commenting your code thoroughly on this assignment will help prepare you for the future assignments!

  • Documentation & Comments - You should document all non-obvious functionality in your code. For example, if there is some complex computation that is not easily understood via identifiers, then this should be clearly documented in a comment. However, you should try to avoid documenting obvious information. For example, adding a comment to a variable named citiesList that states "This is the list that holds the cities" is not likely to be a valuable comment in the future. Part of this grade will also stem from your description of your endpoints in your README file.
  • Modularity - Throughout the course of this semester, one topic that has come up repeatedly is the idea of code maintainability. One of the best ways to help make your code more maintainable in the long run is to make it modular, that is try your best to achieve low coupling and high cohesion. We expect that you will break your project down into logical modules, and where appropriate, files.
  • Identifier Intelligibility - The final code style related item we will look at is the intelligibility of your identifiers. This should be pretty straightforward, use identifier names that correspond well with the concepts you are trying to represent. Try to avoid unnecessarily short (e.g., i) and unnecessarily long identifiers.