2

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
  • 15,294
  • 14
  • 60
  • 85
Cisum Inas
  • 6,390
  • 9
  • 30
  • 50

0 Answers0