Post 9tLOaBQ47ItDZf2QNc by orangelamp@fosstodon.org
 (DIR) More posts by orangelamp@fosstodon.org
 (DIR) Post #9tLKTYjicvFe2xohjE by orangelamp@fosstodon.org
       2020-03-24T20:13:25Z
       
       0 likes, 0 repeats
       
       #javascript Anybody know why this recursive function isn't working right? Instead of picking up where it left off in the loop after calling itself, it's just calling itself once and then  proceeds to ignore the for loop.
       
 (DIR) Post #9tLKTZTnra7ALtNVYm by wizzwizz4@fosstodon.org
       2020-03-24T20:16:24Z
       
       0 likes, 0 repeats
       
       @orangelamp Where's i declared? Looks like a global to me.
       
 (DIR) Post #9tLKUnq5xb6VB2ONrE by wizzwizz4@fosstodon.org
       2020-03-24T20:16:39Z
       
       0 likes, 0 repeats
       
       @orangelamp Where's i declared? Looks like a global to me.JavaScript sucks.
       
 (DIR) Post #9tLLdVgmuYYTRhkr0C by wizzwizz4@fosstodon.org
       2020-03-24T20:29:25Z
       
       0 likes, 0 repeats
       
       @orangelamp Yeah, it's definitely that. The inner loop is setting i to a large value, which is immediately hitting the exit condition of all of the parent for loops. They need to use different values of i.Write let i = 0; or var i = 0; in the for statement.
       
 (DIR) Post #9tLMyQSLf6hHFfXPkG by orangelamp@fosstodon.org
       2020-03-24T20:44:24Z
       
       0 likes, 0 repeats
       
       @wizzwizz4 I just tried both var and let in the for statement [   for (var i = 0;i<temp.length;i++){etc}   ] and they haven't fixed the for loop.Is there a way I can guarantee that i remains local to each instance of the loop?
       
 (DIR) Post #9tLOaBQ47ItDZf2QNc by orangelamp@fosstodon.org
       2020-03-24T21:01:34Z
       
       0 likes, 0 repeats
       
       @wizzwizz4 Ayy, it looks like the issue was with children rather than i.
       
 (DIR) Post #9tLOaBg19zeMN8VAFE by wizzwizz4@fosstodon.org
       2020-03-24T21:02:27Z
       
       0 likes, 0 repeats
       
       @orangelamp And temp. Temp will also cause an issue. All three need let / var before them. (I didn't spot those other two!)