Tell us what’s happening:
Describe your issue in detail here.
I need to understand why I’m getting undefined when i try to console.log(remove()) yet i still pass the task. What am i not getting right?
**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(arr, bookName) {
let newArr = [...arr]
newArr.push(bookName);
return newArr;
// Change code above this line
}
console.log(add(bookList,"Pebbles along the Riverbank"))
// Change code below this line
function remove(arr, bookName) {
let newArr = [...arr]
const book_index = newArr.indexOf(bookName);
if (book_index >= 0) {
newArr.splice(book_index, 1);
return newArr;
// Change code above this line
}
}
console.log(remove(bookList, "Pebbles along the Riverbank"))
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0
Challenge: Functional Programming - Refactor Global Variables Out of Functions
Link to the challenge: