Could someone tell me where I am wrong ?
function add (list,bookName) {
list=bookList.slice();
list.push(bookName);
return list;
}
function remove (list,bookName) {
list=bookList.slice();
let n=list.indexOf(bookName);
if(n>=0){
list.splice(n,1);
return list;
}
}
var newestBookList = remove(add(bookList, 'A Brief History of Time'), 'On The Electrodynamics of Moving Bodies');
At the end newerBookList equals
["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]
instead of
["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]
.