Hi there, I’m working on the Javascript curriculum and this Challenge:
following code will pass the test even though the original array bookList is modified. Can someone confirm?
Summary
// 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
function add(bookList, bookName) {
return [...bookList, bookName]
// Change code above this line
}
// Change code below this line
function remove(bookList, bookName) {
const book_index = bookList.indexOf(bookName);
if (book_index >= 0) {
bookList.splice(book_index, 1);
return bookList;
// Change code above this line
}
}
// console.log(bookList)
// console.log(remove(bookList, "The Hound of the Baskervilles"))
// console.log(bookList)
Fixing the test would be a great challenge for me