Tell us what’s happening:
I’ve cleared all the syntax errors, I didn’t modify the original code and yet the test won’t pass.
Your code so far
var 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 (list, bookName) {
return […list, bookName];
// Change code above this line
}
// Change code below this line
function remove (list, bookName) {
return list.filter(book <= book !== bookName);
// Change 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);
// The global variable
var 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 (list, bookName) {
return [...list, bookName];
// Change code above this line
}
// Change code below this line
function remove (list, bookName) {
return list.filter(book <= book !== bookName);
// Change 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);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 OPR/68.0.3618.112
.
Challenge: Refactor Global Variables Out of Functions
Link to the challenge: