on-internet
← Community

Javascript map add value to exist key

Stack Overflow ·

Hello I've got problem with map in js, I've got list of orders in form like this=> const ORDERS = [ { orderId:1, category:"sport", amount:350, time:'2019-12-15T19:23:30.000Z' }, { orderId:2, category:"sport", amount:350, time:'2019-12-15T19:21:30.000Z' }, { orderId:3, category:"garden", amount:120, time:'2019-12-15T19:25:30.000Z' }, { orderId:4, category:"sport", amount:250, time:'2019-12-15T19:23:30.000Z' } ] I want to create map key based on unique category and amount and map value is a array with times. For example reffered to above order list: key: {category:'Sport',amount:350} and value:

Comments

Sign in or sign up to comment and upvote.

No comments yet.