def array = [Red,Green,Yellow,null]
def map = {'Red': 0, 'Green': 0, 'Yellow': 0 , 'Grey': 0, null : 0}
karate.forEach(array, function(x){ map.put(x,map.get(x) + 1) })
print map
Output : { "Red": 1, "Green": 1, "Yellow": 1, "Grey": 0, "null": 0, "null": 1.0 }