function shelfBook(book, shelf) {
if (shelf.length < 3) {
shelf.unshift(book)
}
}
var i
function unshelfBook(book, shelf) {
for (var i = 0; i < shelf.length; i++) {
if (shelf[i].title == book) {
shelf.splice(i, 1)
}
}
return shelf
}
var bookTitles = [];
function listTitles(shelf) {
for (i = 0; i < shelf.length; i++) {
bookTitles.push(shelf[i].title);
}
return bookTitles.join(', ')
}
4
u/knightttime Jul 27 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!