Hi!
I have been stuck with this exercise a while already, but I really don’t know what I am doing wrong.
This is the code:
// the global variable
var bookList = ["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"];
/* This function should add a book to the list and return the list */
// New parameters should come before the bookName one
// Add your code below this line
function add (bookList, bookName) {
let newBookList = new Array();
newBookList = bookList;
return newBookList.push(bookName);
// Add your code above this line
}
/* This function should remove a book from the list and return the list */
// New parameters should come before the bookName one
// Add your code below this line
function remove (bookList, bookName) {
let newBookList = new Array();
newBookList = bookList;
if (newBookList.indexOf(bookName) >= 0) {
return newBookList.splice(newBookList.indexOf(removedBook), 1);
// Add your code above this line
}
}
var newBookList = add(bookList, 'A Brief History of Time');
var newerBookList = remove(bookList, 'On The Electrodynamics of Moving Bodies');
var newestBookList = remove(add(bookList, 'A Brief History of Time'), 'On The Electrodynamics of Moving Bodies');
console.log(bookList);
And this is what the test is telling me
// running test
newBookList.indexOf is not a function
newBookList.indexOf is not a function
newBookList.indexOf is not a function
newBookList.indexOf is not a function
// tests completed
I have searched the forum, and I see various answers, but I don’t know what is wrong with mine…