Stocks (CSV)

Home

Dataset Information

For this exercise, we will use a handful of CSV files that have been uploaded to the Internet. The CSV files contains historical stock data for a number of companies. There is a CSV file for each of the following symbols: AAPL, GOOGL, MSFT, NFLX, NVDA, and SPOT. The name of each CSV file follows a consistent format (e.g. "daily_adjusted_NFLX.csv" for NFLX). This data was originally obtained from the AlphaVantage API.

Part 1

Write JavaScript code to answer the questions below. Log each of the answers to the console. NOTE: Format all prices as currency using a dollar sign and rounding to two decimal places. NOTE: Format all percentages with a percent sign and rounded to two decimals.

  1. Choose one of the stock symbols listed above (i.e. "NFLX"), and store it in a variable called symbol.
  2. Dynamically compile the corresponding dataset URL using the symbol variable from Question A, and store it in a variable called requestUrl.
  3. Fetch stock data for the chosen symbol, using the requestUrl from Question B.
  4. Display the number of days in the provided data (i.e. 100). NOTE: It is sufficient to just count the number of row objects.
  5. Display the date and adjusted closing price on the earliest day (i.e. "2024-02-05" and "$562.06").
  6. Display the date and adjusted closing price on the latest day (i.e. "2024-06-27" and "$684.34").
  7. Calculate the overall percent change in adjusted closing price from the earliest to the latest day (i.e. "21.76%").

Part 2

Write JavaScript code to answer the questions below. Display the answers on the page in the designated areas. NOTE: when applicable, use the same currency and percent formatting as in Part 1.

  1. Using the designated span elements below, display the stock symbol, the earliest day's date and adjusted closing price, the latest day's date and adjusted closing price, and the overall percent change.


Display

Symbol: TODO

Earliest: TODO

Latest: TODO

Percent Change: TODO