Week 04 - Objects

Lecture

This lecture will focus on building on the basic javascript concepts we learned last week and

View the lecture

Homework

Reading

Read 6.1, 6.3, 6.8 and 6.12. Don't worry if it's not totally clear, I just want you to get familiar with these concepts.

Assignment

Point of Sale systems are used at restaurants and stores instead of cash registers. Create your own simple one, based on this starter code.

Part 1: Your function make_sale(items) should take an array of strings (items) as an argument, and return the total cost of all the items. As you can see from the starter code, there are currently only three possible items in the price_lookup, any items not in the price_lookup should not add to the total.

make_sale(['cat', 'sofa'])
// DESIRED OUTPUT: 15

Part 2: Add functionality that allows a user to add items/prices to the price_lookup. To do so, the user should include a string in the items array with "name=price", before the "name" appears in the array on it's own. For example.

make_sale(['cheese', 'snow=2', 'snow', 'cat', 'snow'])
// DESIRED OUTPUT: 10

Send your work (a jsbin link or similar is fine) to zachary.schwartz@qc.cuny.edu by Thursday March 1st at 9am.