Question: Write a function called 'shoppingList(list)'. The shoppingList function will take in a starting list as an array and return a new function that will allow

 Write a function called 'shoppingList(list)'. The shoppingList function will take in

Write a function called 'shoppingList(list)'. The shoppingList function will take in a starting list as an array and return a new function that will allow us to add to the list. When that return function is invoked with an argument, it will add the argument to the list and return the list. Look below to see how this function is invoked: const groceryList =[ 'eggs ] const addToGroceryList = shoppingList (groceryList); // returns a function addToGroceryList('maple syrup'); // returns ['eggs', 'maple syrup'] const clothesList =[] const addToClothesList = shoppingList ( clothesList); addToClothesList('tshirt'); // returns ['tshirt'] addToClothesList('pants'); // returns ['tshirt', 'pants'] console. log (clothesList); // ['tshirt', 'pants']

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!