Refactor Global Variables Out of Functions - Confusion on returning array

Tell us what’s happening:

I might have missed this earlier, below are two examples; 1st one passes the challenge, the second one doesn’t. I seem to recall that something similar in ruby will work- is this just a JS related rule?

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

// works!
function add (arr,bookName) {
    var newArr = [...arr]
    newArr.push(bookName);
    return newArr;

// does not work!
function add (arr,bookName) {
    var newArr = [...arr]
    return (newArr.push(bookName));
    
**Your browser information:**

User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36</code>.

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

The second function doesn’t work because push() does not return the array on which it was called. Rather, it returns its new length.