Weather Forecast (JSON)

Home

Dataset Information

For this exercise, we will use a JSON file called "weather-data.json" that has been uploaded to the Internet. The JSON file contains weather forecast data that was originally retrieved from the Weather.gov API.

Part 1

Write JavaScript code to answer the questions below. Log each of the answers to the console.

  1. Fetch the weather data using the provided URL.
  2. Display the date this data was generated (i.e. "2021-06-08").
  3. Display the number of periods of available data (i.e. 14).
  4. Use a filtering operation to arrive at a subset of the periods that are daytime only (excluding night-time periods), and store them in a variable called daytimePeriods.
  5. Display the number of daytime periods (i.e. 7).
  6. For each daytime period, display a human-readable weather forecast on that date, including: the period name, temperature (and temperature unit), and a short or long forecast.

Part 2

Write JavaScript code to answer the questions below. Display the answers on the page in the designated areas.

  1. Display the date this data was generated. Use the designated span element.
  2. Display a seven day forecast, using the daytime periods only. Use the designated table element. The table should have four columns ("Period", "Temperature", "Forecast", and "Icon"). There should be a row for each daytime period. Include the period name, temperature (and temperature unit), and a short or long forecast. Also display the weather icon as an image.

Display

Date: TODO

Seven Day Forecast: