- 3
Another problem 😕😕. On recursion
How do all the elements in a nested array https://code.sololearn.com/cA74a62A12A5/?ref=app
11 Respuestas
+ 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);
+ 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 ^^
+ 2
visph oh no! I haven't noticed that at all!!
+ 2
visph i had a like storm on my comments so I didn't notice your notifications for the messages.
+ 2
visph okay bro. It won't happen again. Thanks again
+ 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
+ 2
visph yes I got it. I meant that how do you approach problems on recursion?
+ 2
visph aha. Thank you. I'll keep solving more questions on them 😊 😊 😊 😊
+ 1
if item is array, add addAll(item), else add item... for each items (reduce)
+ 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
- 1
visph please after answering this, how do you approach problems on recursion? How do you solve them? What strategy do you use please?