Skip to content

lmatteis/acme-supermarket-test

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Install

First install the jest devDependency I added using npm install

Then, to run tests and see the program's output, run npm run test

Note: make sure you're using at least node version v8.9.3.

ACME Supermarket

Create a solution for the ACME Supermarket problem.

Description of the problem

ACME's quest for global domination has prompted us to open a supermarket – we sell only three products:

Product code        Name            Price

FR1                 Fruit tea       £ 3.11
SR1                 Strawberries    £ 5.00
CF1                 Coffee          £11.23

Our CEO is a big fan of buy-one-get-one-free offers and of fruit tea. He wants us to add a rule to do this.

The COO, though, likes low prices and wants people buying strawberries to get a price
discount for bulk purchases. If you buy 3 or more strawberries, the price should drop to £4.50. Our check-out can scan items in any order, and because the CEO and COO change
their minds often, it needs to be flexible regarding our pricing rules.

The interface to our basket looks like this (shown in JavaScript):

var basket = new Basket(pricingRules)
basket.add(item)
basket.add(item)
var price = basket.total()

Implement a basket system that fulfills these requirements in JavaScript.

Test Data:

Basket: FR1, SR1, FR1, CF1
Total price expected: £19.34

Basket: FR1, FR1
Total price expected: £3.11

Basket: SR1, SR1, FR1, SR1
Total price expected: £16.61

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%