Object.assign()

Report a typo

You have two objects:

const shoppingList = { milk: 1, bread: 2, sugar: 1};
const addingList = { apple: 4, lemon: 2 };

Copy all properties from addingList to shoppingList using Object.assign(), in order to get this:

const shoppingList = { milk: 1, bread: 2, sugar: 1, apple: 4, lemon: 2 }

Tip: Do not console log the output. It's taken care of internally

Sample Input 1:


Sample Output 1:

{ milk: 1, bread: 2, sugar: 1, apple: 4, lemon: 2 }
Write a program in JavaScript
const shoppingList = { milk: 1, bread: 2, sugar: 1};
const addingList = { apple: 4, lemon: 2 };
//write your code here
___

Create a free account to access the full topic