0

I have a big for loop (but I have condensed it in a few lines below), and in it I define a few variables, per se like so:

for(i = 0; i < localStorage.length; i++){
  var a = localStorage.key(i)
  var b = localStorage.getItem(a)
  cal.addEvent(a, b, '8/7/2020', '8/7/2020')
}

In my addEvent method, I want to use the CURRENT values of a and b, but instead it always just gives me the value of a and b for the last value of i in the for loop. How can I get the current values of a and b for the CURRENT value of i?

0 Answers0