Skip to content
Advertisement

How to add new value with same key to document

I need to write down a category and its cost in category object. Now, in my code example, I am adding the products: $50 category to the user. After execution, ‘categories’: { products: ’50$’ } is displayed in the console. But if you add products: 1000$ again, it will overwrite and output ‘categories’: { products: ‘1000$’ }. And I need to display ‘categories’: { products: ‘$50’ , products: ‘$1000’ }. How can this be implemented?

JavaScript

Advertisement

Answer

Instead of

JavaScript

use

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement