I have an array of numbers like this ...
a= [28, 67, 20, 38, 4, 39, 14, 84, 20, 64, 7, 24, 17, 8, 7, 6, 15, 52, 4, 26]
I need to check if each of the numbers has more than 30, and if so, I want to count this number and count the number of numbers more than 30. I have this, but it does not work yet
def late_items
total_late = []
if a.map { |i| i > 30}
total_late << i
end
self.late_items = total_late.count
end
source
share