Rideshare

Home

Part 1

Write JavaScript code to process the provided rideshare variable to answer the questions below. Log each of the answers to the console.

  1. Display a human-friendly message to denote the driver's first name (i.e. "Your driver is Danny").
  2. Display the license plate number (i.e. "ABC-1234").
  3. Display the number of stops this trip makes (i.e. 3).
  4. Display the destination of the first stop (i.e. "Logan Circle").
  5. Display the destination of the last stop (i.e. "Washington Circle"). NOTE: your solution should work regardless of how many stops there are (i.e. should reference the last item dynamically, not assume the third stop is necessarily the last).
  6. Loop through each of the stops and display that stop's passenger name, one at a time (i.e. "Vishal", then "Clara", then "Lee", each on a separate line).
  7. Use a mapping operation to arrive at an array of just the numeric fare values, store them in a variable called fares, and display them.
  8. Calculate and display the total fare for the entire trip, which is equal to the sum of all the fares for all passengers. Format the total fare as USD, with a dollar sign and rounded to two decimal places. HINT: use an accumulator approach in conjunction with Question G, or use the d3.sum() function from the d3-array library.


Part 2

Write JavaScript code to process the provided rideshare variable to answer the questions below. Display the answers on the page in the designated places.

  1. Display the driver's first name. Use the designated span element.
  2. Display the vehicle's make, model, and license plate number. Use the designated span element.
  3. Loop through each of the stops and display that stop's passenger name, one at a time (i.e. "Vishal", then "Clara", then "Lee", each in a separate list item). Use the designated ol element.

Driver: TODO

Vehicle: TODO

Passengers: