Hello, It’s my first time touching Java and i’m following the course on FCC.
I have a really hard time finding the issue with my code for this challenge…
Here is the link to the challenge :
To quickly explain the issue i have, it’s about the first test. the global variable bookList should stay unchanged, but it’s not being accepted. Even though console.log(bookList) shows me what’s asked… The rest are OK.
Here’s the code;
// 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(bookArray,bookName) {
let listAdd = bookArray; // Creating another variable to keep bookList unchanged
listAdd.push(bookName);
return listAdd;
// Change code above this line
}
// Change code below this line
function remove(bookArray,bookName) {
let Listing = bookArray; // creating another variable to keep bookList unchanged
const book_index = Listing.indexOf(bookName);
if (book_index >= 0) {
Listing.splice(book_index, 1);
return Listing;
// Change code above this line
}
}
console.log(bookList) // it gives me what is tasked, [ 'The Hound of the Baskervilles','On The Electrodynamics of Moving Bodies','Philosophiæ Naturalis Principia Mathematica','Disquisitiones Arithmeticae' ]
// the only change is from "" to ''...
Thanks for any answer to enlighten me, as i’m really a newbie i would prefer if you could start with simple things.