Exercise: Arrays

Let's solve some exercises on arrays before moving onto the next chapter.

Problem statement #1

In the code widget below, write a method to calculate the number of zeros in the array by passing a block to the count method.

Example

array1 = [0,1,1,0,0]
result = 3

Let’s try it for ourselves, before looking at the solution.

Get hands-on with 1400+ tech skills courses.