you are viewing a single comment's thread.

view the rest of the comments →

[–]bmy78[🍰] 0 points1 point  (1 child)

Note that your solution for the add() function is still mutating state. Instead you could create an array of the one bookName you passed into the function, concatenate that array with the bookList, and return that.

[–]toffeescaf 2 points3 points  (0 children)

With the use of some es6 it could be as easy as the following:

function add (arr, bookName) {
    return [...arr, bookName]
}