Hi there. It seems the bookList
array is changing. I looked up how to clone an array and tried using the Spread Operator, for
loop and Array.from
.
// The global variable
const bookList = ["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"];
// Change code below this line
let list = [];
list = [...bookList]
function add(list, bookName) {
list.push(bookName);
return list;
// Change code above this line
}
// Change code below this line
function remove(list, bookName) {
const book_index = list.indexOf(bookName);
if (book_index >= 0) {
list.splice(book_index, 1);
return list;
// Change code above this line
}
}
Thanks.