0
/ 1.0
The following method takes an integer array as a parameter. Write code that loops through the array to find the value 1. If 1 is found,...
The following method takes an integer array as a parameter. Write code that loops through the array to find the value 1. If 1 is found, increment a counter
variable. Once the loop finishes, return the value of the counter
, which is the number of 1's found. If the array is empty, return 0.
Examples:
oneFinder({1,1,1}) -> 3
oneFinder({4,1,4,0,0,0,2,4,4,1,4}) -> 2
oneFinder({2}) -> 0
Your feedback will appear here when you check your answer.