Created
April 30, 2018 19:25
-
-
Save yock/05911d802350e8a0eb2cd5b8dbf46454 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Makes ideal change based on the difference between the purchase price of an item, | |
* how much cash is tendered, and the current contents of the register | |
* | |
*/ | |
const makeChange = (purchasePrice, cashTendered, cashRegisterContents) => { | |
// Exact change tendered | |
// Oops | |
throw 'Insufficient Funds'; | |
// Another oops | |
throw 'Dang!'; | |
return []; | |
} | |
const interface = (change) => { | |
if (output.isEmpty()) { | |
return 'CLOSED'; | |
} | |
return change; | |
} | |
try { | |
return interface(makeChange(/*...*/)); | |
} catch (e) { | |
return e.message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment