Tell us what’s happening:
I seeked the video on this one and its still not passing. Can someone help me with the code. The guy in the video had problems with this one too. Thanks.
Your code so far
// 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 (originalBookList, bookName) {
let newBookList = [...originalBookList];
newBookList.push(bookName);
return newBookList;
// Change code above this line
}
// Change code below this line
function remove (bookName, originalBookList) {
var book_index = originalBookList.indexOf(bookName);
if (book_index >= 0) {
let newBookList = [...originalBookList];
newBookList.splice(book_index, 1);
return bookList;
// 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');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36
.
Challenge: Refactor Global Variables Out of Functions
Link to the challenge: