Tell us what’s happening:
Hello, I am trying to replicate the array so that i can modify it, but it’s not working. Could someone tell me why? Thanks!
Your code so far
// 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(bookName) {
const bookL = bookList
bookL.push(bookName);
return bookL;
// Change code above this line
}
// Change code below this line
function remove(bookName) {
const bookL = bookList
const book_index = bookL.indexOf(bookName);
if (book_index >= 0) {
bookL.splice(book_index, 1);
return bookL;
// Change code above this line
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Functional Programming - Refactor Global Variables Out of Functions