The first module you will write will store coffee order information in a simple database, not unlike writing down the orders by hand. Each order will be stored by the customer’s email address. To get started, you will only keep track of a text description of the order, like “quadruple espresso” (Figure 8.6).
Later, you will also keep track of the size, flavor, and caffeine strength of each coffee order. The customer’s email address will serve as the unique identifier for the entire order, so all of the order details will be associated with a single email address. (Sorry, coffee addicts! Only one order per customer.)
Create a new file called scripts/datastore.js.
Next, in index.html, add the
<script>
tag to include the new file in your project.
<!doctype html> <html> <head> <meta charset="utf-8"> <title>coffeerun</title> </head> <body> <script src="scripts/datastore.js" charset="utf-8"></script> </body> </html>
Save index.html. In scripts/datastore.js
, begin with the basic IIFE for your module structure:
(function (window) { 'use strict'; // Code will go here })(window);
Now that the skeleton of your module exists and has a corresponding
<script>
tag, it is time to attach it to the
namespace for your application.
3.148.107.254