Skip to content

Instantly share code, notes, and snippets.

@zavod008
Created November 26, 2018 19:39
Show Gist options
  • Save zavod008/90f2210814e2c2116d421c4ab6bce9ae to your computer and use it in GitHub Desktop.
Save zavod008/90f2210814e2c2116d421c4ab6bce9ae to your computer and use it in GitHub Desktop.
if (room.book.length > 0) {
let book = room.book.reduce((result, item) => {
return result + item.count;
}, 0);
console.log(book);
if (item.count + 1 > room.free || book === room.free) {
return false;
}
room.list.forEach(itemTest => {
if (itemTest.group !== item.group) {
itemTest.class = 'hide';
}
});
room.book.forEach(itemTest => {
if (itemTest.id === item.id) {
itemTest.count = item.count + 1
} else {
room.book.push({
count: item.count + 1,
group: item.group,
id: item.id
});
}
})
} else {
room.book.push({
count: item.count + 1,
group: item.group,
id: item.id
});
}
item.count += 1;
item.class = 'active';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment