#How is the index not being incremented when console.log() it passes 0 index 3 times.

14 messages · Page 1 of 1 (latest)

lime forum
#

your function is recursive.

sonic marsh
#

yes but i++ is incremented and is passing through backtrack but stays 0

lime forum
#

no, backtrack is called again with i = 0

#

so it starts again at 0

#

the "passes 0 index 3 times" are in different nested function calls

#

this is a case you should really step through with a debugger and not just console.logs

viral scaffold
lime forum
#

i feel like i remember trying that and it just... not really working in node

sonic marsh
#

ah I see whats happening. you initialize then check the condition. after that you go to the statement. you only go back to increment when the statement is complete but in this instance were using reccusion

viral scaffold
lime forum
#

well there's some stuff here seeming to support it

spark joltBOT
#
// Track amount of indentation required via `console.group()`.
lime forum
#

but idk, i just don't remember it working. maybe my memory's faulty though