Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const object = {
- 1234: {
- quantity: 8
- },
- 5678: {
- quantity: 16
- },
- 9101: {
- quantity: -2
- }
- };
- const [index] = Object
- .entries(object)
- .reduce(([maxKey, maxValue], [key, value]) => value.quantity >= maxValue.quantity ? [key, value] : [maxKey, maxValue]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement