Skip to main content

Practice · 3 of 4

Debug: crash on empty input

CHALLENGE
Difficulty: beginner+25 XP

average(int[] scores) throws ArithmeticException on an empty array. Fix it to return 0 for an empty array and the correct int average otherwise (keep integer division). Signature stays the same.

Back to lesson: Practice: Testing and debugging reps