Last active
January 15, 2018 15:44
-
-
Save royletron/1dc4d32ce5d363f296ee4653f1586651 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
var books = [ | |
{ | |
id: 1, | |
name: 'Intro to Bash', | |
description: 'A great book about bash', | |
info: { | |
stock: 3, | |
copies: 3 | |
} | |
}, | |
{ | |
id: 2, | |
name: 'Fundamentals of Web', | |
description: 'Get to grips with the fundamentals of web tech', | |
info: { | |
stock: 2, | |
copies: 2 | |
} | |
} | |
] | |
var ledger = [ | |
{ | |
user: 'Darren', | |
action: 'borrow', | |
book: 1 | |
}, | |
{ | |
user: 'Kiki', | |
action: 'return', | |
book: 2 | |
}, | |
{ | |
user: 'James', | |
action: 'borrow', | |
book: 1 | |
} | |
] | |
function updateStock() { | |
// This function should go through the ledger, determining whether action was | |
// to borrow or return a copy of the book, and then increment or decrement the | |
// 'stock' parameter of the relevant book | |
} | |
updateStock(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment