What is wrong whit this?

I don’t know why this doesn’t run
I put function add(list,bookName) {
return […list,bookName];
It supose to run with the new parameter “list”, same as the remove function.Why?

   **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(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 (X11; Ubuntu; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0

Challenge: Refactor Global Variables Out of Functions

Link to the challenge:

When I paste your code into the challenge I am getting the following error in the output console:

SyntaxError: unknown: Unexpected token (19:0)

Are you seeing this? It is telling you that you have an error in your code and it actually points to the exact character that is causing this error. You fix this and your code will pass.

Also, I will admit that the

// Change code above this line

comment might be in the wrong place since you actually have to remove a character below that line in order to get your code to work.

1 Like

Thank u bro, you had right

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.