✅ – Pink Hat – 00-54 Feb 15
in this code
why does
this.pattern[2]
get printed 3 times?
When it should be printing
46 Replies
Try caching
this.j
as a local variablecaching it?
Yes, similarly as you do with
i
regarding this.i
like this?
}(this.i, 0))
-> }(this.i, this.j))
nothing
still the same result
Can you add labels to
console.log
so it's more readable, which log refers to what value?sure
And show output
Where's that "3" log coming from? Add it label too
the 3 is the label
it was originally this
then so I could run it in chrome
Its a result of
this.pattern[2]
being run 3 times
I think it's happening because this.i is already fully changed before the setTimeout occursCan you add counters to
pattern
too?
Show the console output - i suppose each pattern will have counter: 3
Yes
You could await timeout call