3

How do I get the current iteration count of my for...of loop?

let iterable = new Set([1, 1, 2, 2, 3, 3]);

let i = 0;
for (let value of iterable) {
  console.log('value in Iteration count = ' + i + ' is :' + value);
  i++;
}

This is what I currently have, is there some kind of built in iteration count variable which can replace my variable i?

Jonathan Lam
  • 16,831
  • 17
  • 68
  • 94
Cisum Inas
  • 11,552
  • 11
  • 40
  • 55

0 Answers0