Run generator function in forEach function callback for each element in array