Git Product home page Git Product logo

checkout's Introduction

Checkout

Debugging is so much more fun when it's about money!

This shopping cart isn't quite living up to our expectations. We're losing money on shipping. We're losing money on handling. We're losing customers due to errors.

Correct the errors and get us back on track.

  1. Fork & Clone in ~/wdi/exercises.
  • Change to the "checkout" dir.
  • Open index.html
  • Fix scripts/shopping_cart.js (and only shopping_cart.js)

Shipping Fees:

Weight:

  • < 5lbs: $0
  • 5 - 50lbs: $5
  • Over 50lbs: $10

Size:

  • Small: $0
  • Large: $50
  • Ludricous: $2550

Add all appropriate shipping fees.

Debugging Suggestions:

Remember, take small steps. Get one thing working, commit, and move to the next. Don't be afraid to comment out some code. If you need to, replace it with a simple hard-coded value for a little while.

If something looks overwhelming, break it down. Look at one function at a time. Each function has its own responsibility.

You do not need to change any code in the app.shoppingCart.render() function.

Suggested progression:

  1. Inspect app.ShoppingCart. What properties and methods does it have? What is their responsibility?
  • Get the unordered "items" list to work.
  • Simplify. Comment out some items in app.initialize to get a simple example.
  • Get each function to work without errors.
  • Calculate the correct Subtotal.
  • Calculate the Shipping.
  • Calculate the Total Cost.

Done?

When completed, you should see:

Items

Name: EloquentJavascript | Price: $20.00
Name: Raspberry Pi | Price: $35.50
Name: Trampoline | Price: $339.50
Name: Tesla X1 | Price: $79,900.00

Subtotal:   $80,295.00
Shipping:    $2,615.00
Total cost: $82,910.00

Bonus

Bonus 1: Books always have free shipping, regardless of size or weight.

Bonus 2: Render the shipping cost for each item (requires changes to app.shoppingCart.render).

checkout's People

Contributors

jball23 avatar andrewsunglaekim avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.