var fruits = { 'apple': { 'color': 'green', 'sort': 'Granny Smith', 'Country': 'Russia', 'price': 68 }, 'orange': { 'color': 'orange', 'sort': 'Valencia', 'country': 'Spain', 'price': 100.99 }, 'pear': { 'color': 'red', 'sort': 'Conference', 'country': 'Cyprus', 'price': 120.59 } }; 

Closed due to the fact that it is off-topic by participants aleksandr barakin , Kromster , 0xdb , Suvitruf , LFC 8 Apr at 7:24 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- aleksandr barakin, 0xdb, Suvitruf, LFC
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    A call to Object.values(fruits) converts an object into an array of its properties.

    and using convolution ( Array.reduce ) of this array, you can get the sum of nested properties:

     var fruits = { 'apple': { 'color': 'green', 'sort': 'Granny Smith', 'Country': 'Russia', 'price': 68 }, 'orange': { 'color': 'orange', 'sort': 'Valencia', 'country': 'Spain', 'price': 100.99 }, 'pear': { 'color': 'red', 'sort': 'Conference', 'country': 'Cyprus', 'price': 120.59 } }; let c = Object.values(fruits).reduce((a,v) => a + v.price, 0) console.log(c)