I used Array.from(); to copy an array in functional programming section, it produces the same output as the solutions do.. but it won't pass the test

Tell us what’s happening:
Describe your issue in detail here.

  **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(list, bookName) {
   let newArr = Array.from(list);
   newArr.push(bookName);
   return newArr;
// Change code above this line
}

// Change code below this line
function remove(bookName) {
  let tempArr = Array.from(list);
  const book_index = tempArr.indexOf(bookName);
  if (book_index >= 0) {

    tempArr.splice(book_index, 1);
    return tempArr;

  // Change code above this line
  }
}
console.log(add(bookList, "newBook"));
console.log(bookList);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44

Challenge: Refactor Global Variables Out of Functions

Link to the challenge:

You are missing this requirement

Declare function parameters - any computation inside a function depends only on the arguments passed to the function, and not on any global object or variable.

1 Like

My bad I forgot to do declare list parameter in second function. Thanks for help.

1 Like

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