0

How to return numbers from foreach function in intervals?

I must to return from my foreach function number in intervals, so for example i need to return 3,7,11,15,19,23,27,31 etc.

data.foreach(async (e, index) => {
    await this.getNumberInIntervals(e.id, index+4); // in this parameter I must be provide a numbers with interval by 4
})

can someone tell me how can i do it?

this is a diffrent question than this: Is there a difference between foreach and map?

1 Answers1

0
data.foreach(async (e, index) => {
    await this.getNumberInIntervals(index * 4 + 3);
})
Simon
  • 369
  • 1
  • 9