X450: For Loop: Add First Five

Given an int[] nums array, return the sum of the first five elements from the array. Note that nums could have fewer than five elements, in which case return the sum of all elements

Examples:

sumFirstFive({1,1,1,1,1,1,1,1}) ->  5
sumFirstFive({2,2,2}) -> 6

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.