Array Average

L1 Easy Arrays & Hashing
Concept
An average is the sum divided by the size. Dividing integers produces a fractional value, so convert to Double before dividing.
Return the average of the integers in nums as a Double. If the array is empty, return 0.
Examples
▸ nums = [1, 2, 3, 4]
→ 2.5
▸ nums = []
→ 0
▸ nums = [-2, 2]
→ 0
Progressive Hints
Hint 1 · Nudge
Sum everything up, then share it out equally among the items.
Hint 2 · Plan
Handle the empty array by returning 0. Otherwise add all elements, divide by the count using decimal math, and return the result.
Hint 3 · Approach
If empty, return 0. total = sum of all n. Return total divided by the count, as a decimal.
Output
// Run your code to see the output here.