Skip to content

Instantly share code, notes, and snippets.

@royletron
Last active January 15, 2018 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save royletron/1dc4d32ce5d363f296ee4653f1586651 to your computer and use it in GitHub Desktop.
Save royletron/1dc4d32ce5d363f296ee4653f1586651 to your computer and use it in GitHub Desktop.
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