Refactor Global Variables and other issues

Refactor Global Variables and other issues
0
#1

Tell us what’s happening:
/*
This is a general comment-The problems that I am seeing are written badly-the instructions are not clear in what they are asking, that should be solved. I have been in too many sprints/daily stand ups to see that this is a problem because the ask needs to be very clear for any programmer to solve, step by step. I am noticing lately that the problem sets are written haphazardly. Please update.*/

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"];

/* This function should add a book to the list and return the list */
// New parameters should come before the bookName one

// Add your code below this line
function add (bookName) {
  
  return bookList.push(bookName);
  
  // Add your code above this line
}

/* This function should remove a book from the list and return the list */
// New parameters should come before the bookName one

// Add your code below this line
function remove (bookName) {
  if (bookList.indexOf(bookName) >= 0) {
    
    return bookList.splice(0, 1, bookName);
    
    // Add your 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 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/refactor-global-variables-out-of-functions

#2

If you have specific recommendations, we welcome you to create an issue for this or any other challenge you think could be worded differently. On the issue you can explain what you think should be different and if there is a consensus among the collaborators, you can create a PR to implement the changes. Just make sure you are looking at the current version of the challenge on the master branch, because many of the challenges have been changed/improved but have yet to be deployed to production yet.