Initializing CoffeeRun on Page Load

Your DataStore and Truck modules work correctly. You have been able to instantiate a new Truck on the console, supplying it a new DataStore as part of its creation.

Now you are going to create a module that performs these same steps when the page loads. Create a scripts/main.js file and add a <script> tag to index.html.

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>coffeerun</title>
  </head>
  <body>
    <script src="scripts/datastore.js" charset="utf-8"></script>>
    <script src="scripts/truck.js" charset="utf-8"></script>>
    <script src="scripts/main.js" charset="utf-8"></script>
  </body>
</html>

Save index.html. You are going to add an IIFE to main.js, as you have done with the other modules, ...

Get Front-End Web Development: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.