Recursive Javascript Functional Programming Help I don\'t want the exact answer,
ID: 3567077 • Letter: R
Question
Recursive Javascript Functional Programming Help
I don't want the exact answer, I just need help putting me in the right direction and any extra information that might come in handy with this problem. I understand what I need to do, just not how to actually do it.
I'm supposed to write a recursive function that only takes in ONLY an array and reverses the order of the contents.
So far I have something like:
recursive(array)
{
//base case
if(array.length <= 1)
return array;
//Under normal circumstances I would do something like create a new var array2 and just push all items popped
//from array into array2. However, I can't really define new variables in this situation because it's a recursive
//function and it only takes in one array as a parameter. I feel like if I understood a bit more javascript (we are just
//doing a brief overview of it in class) then I would know more things I could do. But as it stands, I am lost. Any
//help on converting this to a recursive function would be so helpful.
}
Explanation / Answer
you can use method recursively in this way
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.