With the given shoppingList array (within the JS file), use array destructuring to assign each array within the shoppingList array its own variable. Then, reinitialize the shoppingList array so it is...

1 answer below »

With the given shoppingList array (within the JS file), use array destructuring to assign each array within the shoppingList array its own variable. Then, reinitialize the shoppingList array so it is a single array containing all of the values from the original array.


Original Shopping List:



Shopping List after being reinitialized:




  • after the shoppingList array has been reinitialized, using the array.prototype.map method, map over the newly initialized shoppingList array. You should do the following within the map method:

    • include a parameter for index

    • utilize the array.prototype.push method to push the current value being mapped over into the appropriate key/value pair in the obj variable

    • you will need to implement some sort of logic to check the index of the current item



Answered Same DayOct 10, 2021

Answer To: With the given shoppingList array (within the JS file), use array destructuring to assign each array...

Jyothi answered on Oct 11 2021
119 Votes
let shoppingList = [[ 'eggs', 'milk', 'butter' ], [ 'cleaner', 'trash bags', 'detergent' ], [ 'thank you card', 'pens', 'gift wrapping' ], [ 'shoes', 't-shirt', 'slacks' ]];
console.log(shoppingList)
let obj = { cleaning: [], gifts: [], clothing:[], grocery: [] };
var...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here