- 3

Another problem 😕😕. On recursion

How do all the elements in a nested array https://code.sololearn.com/cA74a62A12A5/?ref=app

12th Jul 2021, 3:45 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
11 Answers
+ 2
that's quite easy as excuse ;P however, I'm agree to help you once again... but it could be the last time if such "mistake" happen again ^^ const addAll = a => a.reduce((a,v) => a+(Array.isArray(v) ? addAll(v) : v), 0);
12th Jul 2021, 4:17 PM
visph
visph - avatar
+ 2
why would I help you again? you've been unfair by removing the best answer mark from my last helpful answer about 7-8 hours after setting it, and you even not answer to my question asking why you did so ^^
12th Jul 2021, 4:05 PM
visph
visph - avatar
+ 2
visph oh no! I haven't noticed that at all!!
12th Jul 2021, 4:08 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
visph i had a like storm on my comments so I didn't notice your notifications for the messages.
12th Jul 2021, 4:12 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
visph okay bro. It won't happen again. Thanks again
12th Jul 2021, 4:18 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
visph but please how do you approach the problems? How do you solve them? I keep trying and I spend hours to no avail
12th Jul 2021, 4:19 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
visph yes I got it. I meant that how do you approach problems on recursion?
12th Jul 2021, 4:23 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 2
visph aha. Thank you. I'll keep solving more questions on them 😊 😊 😊 😊
12th Jul 2021, 4:31 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar
+ 1
if item is array, add addAll(item), else add item... for each items (reduce)
12th Jul 2021, 4:22 PM
visph
visph - avatar
+ 1
by considering the problem... and applying the solution wich seems to fit ^^ there's no generic rule... (as far as I know) sometimes it's harder, and could require multiple try and fail... but by solving such problem, the logic come more easily by the time and the practice ;P
12th Jul 2021, 4:28 PM
visph
visph - avatar
- 1
visph please after answering this, how do you approach problems on recursion? How do you solve them? What strategy do you use please?
12th Jul 2021, 3:45 PM
جوردن آهو ماولی
جوردن آهو ماولی - avatar