CompSci 290
Spring 2021
Web Application Development

Working with Data

This project is intended for you to learn the basics of JavaScript programming using data, either encoded directly in your program as a variable or loaded dynamically from an API as JSON.

Submitting Your Work

This project will be added to your portfolio_NETID repository so there is one single place we can go to find your work during the semester. To submit this project:

All your pages must display the way you expect in the latest version of Google's Chrome browser and written following standard Coding Conventions that is validated online.

Specification

Implement the following pages using plain JavaScript 6 (i.e., not any kind of framework that claims to make it easier). We strongly suggest develop your iteratively: making a few small changes at a time and using the Developer Tools: the Console to try JavaScript statements out interactively and Breakpoints to see what is happening in your code.

Part 1: JavaScript - Word Game

Implement a page that plays a word game with the user, such as:

The user can interact with your page by either providing the word(s) to start (in which case you implement the "AI" algorithm) or guessing letters to reveal the secret word(s) (in which case you implement the rules, feedback, and perhaps a "clever cheating" algorithm). The page design is not expected to be amazingly stylish, but any styling should be provided using CSS styles that are changed using JavaScript when specific game conditions are detected.

To simplify the project, restrict the words used for your game's dictionary to all "useful" 5 letter words, given in this file. Rather than reading this file from its source, convert it manually into a single JavaScript String and then algorithmically into whatever data structure you think will best serve as a dictionary for the word game you implement. For example, it may just be a sorted list, or a set, or a map from some characteristic of some words to the words sharing that characteristic.

Along with the game itself, the page should also contain the following:

Part 2: Web API - Plotting Data

Tell a "data story" about the world by combining multiple data values about the world's countries and visualize their relationship by plotting the results on a map. For example, this week's exercise might be seen as proposing a theory between the magnitude of recent earthquakes based on where the ISS is :) Another example might be comparing the length of a country's coastline with the number of environmental international agreements it has and its population's median age? Your story can be serious, curious, interesting, funny, or sarcastic --- whatever you find interesting about the data!

The CIA's World Factbook contains a wealth of comparable data on the world's countries (here is its entry on the United States) and Ian Coleman has kindly done the work to convert its data to JSON. In some cases, it may also be helpful to have a list of all countries or the ISO Country Codes. You may also include (and attribute!) data from other sources if it relates to most countries in the world and is relevant to your story (such as worldwide COVID data or country flags (note Leaflet's icon must use PNG, JPG, or GIF formatted images rather than the more web-friendly SVG format)).

Thus your task for each country will be to

Along with the plotted data itself, the page should also contain the following:

To make the data interactive, include the following features on the page:

Since the Factbook's JSON is big and complex (almost 14MB of text data!), we have made a version that is just the United States for you to study and test more easily (but your submission should work for the entire world, NOT just this US data). We have also provided a Duke-hosted copy of the entire Factbook, as well as some other country data referenced above for you to access in your site to make things more manageable (so do not push this data or your own modified version into your individual Gitlab repository).

Here is the documentation for the Leaflet API used to display the map on this page (note, since we have not provided many tiles, you do not need to support letting the user zoom the map in and out):