Calculate the Mean

Published by romancoding in

Create a function that takes an array of numbers and returns the mean (average) of all those numbers as a string.

Examples

mean([1, 0, 4, 5, 2, 4, 1, 2, 3, 3, 3]) ➞ 2.55

mean([2, 3, 2, 3]) ➞ 2.50

mean([3, 3, 3, 3, 3]) ➞ 3.00

Notes

  • Round to two decimal places.
  • You can expect a number ranging from 0 to 10,000.
  • Remember to return the result as a string.
Watch a quick demo on how Edabit works.