The Daily Average
EasyAcc. 94.2%
+20 XP 8
Statistical Balance
The average (mean) is the sum of all elements divided by the total number of elements.
The Assignment
Your function receives an array values.
- Calculate the sum of all elements in
values. - Divide the sum by the length of the array.
- Print the result.
- If the array is empty, print 0.
01EXAMPLE 1
Input
values = [10, 20, 30]Output
20Explanation: 60 / 3 = 20.
Constraints
- Handle empty arrays to avoid Division by Zero.
- Use values.length.
ArraysLoopsMath
JavaScriptSystem handles I/O — write your function only
Loading...
2 Hidden
Input Arguments
values[10,20,30]
Expected Output
20
Click RUN to test your solution