Debugging

Your last method to add to the Truck.prototype object is printOrders. This method will get an array of all of the customer email addresses, iterate through the array, and console.log the order information.

The code for this method is very similar to other functions and methods you have already written. But it will start out with a bug, which you will find using Chrome’s debugging tools.

Let’s take this step by step. Start by creating the basic version of printOrders in truck.js. In the body, you will retrieve all the coffee orders from the db object. Then you will use the Object.keys method to get an array containing the email addresses for the orders. Finally, you will iterate through the email address array and run a callback ...

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.