+ 2

Js question

why this recursive function does not show me any out put in console? function reverse(a) { if (!a.length) return a; return reverse(a.slice(1)).concat(a[0]) } var a=[3,5,7,6,8]; console.log(reverse(a));

6th May 2020, 8:11 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
10 odpowiedzi
+ 3
Ai.dz Just an interesting fact : Do you know about the reverse method? var a=[3,5,7,6,8]; console.log(a.reverse()); // 8,6,7,5,3 Would give you the same result :))
6th May 2020, 11:33 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
Ai.dz That's really awesome :)) Another challenge you can take is implementing the sort method :))
7th May 2020, 12:01 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Did you mean in SoloLearn Because I have tried it now It gives output
6th May 2020, 8:14 PM
ycsvenom
ycsvenom - avatar
+ 1
In SoloLearn
6th May 2020, 8:16 PM
ycsvenom
ycsvenom - avatar
6th May 2020, 8:17 PM
ycsvenom
ycsvenom - avatar
+ 1
If you want to make it outside just link it
6th May 2020, 8:18 PM
ycsvenom
ycsvenom - avatar
+ 1
Hey Brother Rahim, yes, I know that there are already made methods, but I was just trying to do it my self using the recursion ^^ Thank you ^^
6th May 2020, 11:51 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
0
I am trying it in soloLearn actually. where did you try it?
6th May 2020, 8:15 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
0
oh yeah I just tried it using web browser, yup it worked Thank you Brother ^^
6th May 2020, 8:17 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
0
I am kinnda beginner, but yeah it looks a good idea to try ^^
7th May 2020, 12:19 AM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar