Hash Sum Exercise in Ruby
In this guide you will learn how to return the sum of a hash where the values contain numbers.
Guide Tasks
- Read Tutorial
- Complete the Exercise
Summary
Build out a hash sum that returns a sum of a hash.
Exercise Description
"Define a hash_sum that will return the sum of a hash where the values contain numbers and it will return 0 for an empty hash."
Example Data
' invoices = {
google: 100.0,
yahoo: 105.22,
twitter: 42.50
} '
Real World Usage
This exercise can be used to total a hash data type that is holding invoices to provide a grand total, great for an accounting department for example.