DEV Community

Justin
Justin

Posted on

JS Challenge: Sum of the values of an object's properties

Steps involved:

  1. Get the object's values into an array using Object.values()
  2. Use Array.prototype.reduce() to find the sum of the values
expenses = {grocery: 23.45, cleaners: 17.88, uber: 12.25, tip: 2.00}
Object.values(expenses).reduce((total, value) => 
  total + value, 0
) //returns the sum of values -> 55.58
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video 🎥

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay