← Back to challenges

Cricket Balls to Overs!

JavaScriptHardnumbersmath

Instructions

In cricket, an over consists of six deliveries a bowler bowls from one end. Create a function that takes the number of nBalls bowled by a bowler and calculates the number of overs bowled by him/her.

Examples

totalOvers(2400) ➞ [400]

totalOvers(164) ➞ [27.2]
// 27 overs and 2 balls were bowled by the bowler.

totalOvers(945) ➞ [157.3]
// 157 overs and 3 balls were bowled by the bowler.

totalOvers(5) ➞ [0.5]

Notes

The number following the decimal point represents the balls remaining after the last over. Therefore, it will only ever have a value of 1-5.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: No Yelling