Code for recursion finally working - Grabbed recursion, back to studying

Depending on how you are reducing the problem, unshift can help a lot.

1 Like

@JeremyLT Yes, I noticed. But I’ve obtained all kinds of arrays except what I need.

If others can do it, you can as well. I recommend you watch this yt video so you can grasp the idea about recursion.

1 Like

in the last code you posted there is no recursion, do you have an update?

1 Like

Hello @ILM here’s my updated code,

function rangeOfNumbers(startNum, endNum) {
  if (startNum > endNum) {
  return [];
 } else {
   const arr = [endNum - startNum + 1];
   arr.unshift(startNum++);
   return arr;
 }
} console.log(rangeOfNumbers(4, 9));

@codesmark Thank you for your encouragement, I’ll watch it as soon as I can!

You still are not calling rangeOfNumbers from inside of rangeOfNumbers.

  function multiply(arr, n) {
    if (n <= 0) {
      return 1;
    } else {
      return multiply(arr, n - 1) * arr[n - 1];
    }
  }

what do you want here? you and with arr that contains one single number. It doesn’t seem what you want to get

I officially give up.

Let me explain: I did the HTML CSS course and did well because you don’t have to think, you have to arrange. I have the brain of an artist. If you look at my portfolio at code pen you’ll see that. Now, I love web design. But HTML and CSS are not enough. I so badly wanted to do the JavaScript course because that way I could do web design much much better. But this is programming. This requires the brain of a mathemathician. I don’t have that kind of brain. I enjoyed the course, it was great being challenged in so many ways. This is the second time I do it because so many things I had passed just looking at the solutions (like recursion). This time I wanted to do it right. But, you can’t have pears from an appletree. And I’m an appletree who cannot bear pears. This week I was called from the local art gallery for an interview. Maybe I’m forcing things here and this is not my destiny. Maybe I’m just an artist and a poet. And I know a good one, if you excuse my unmodesty. I enjoyed the courses very much, I learned to view things differently and it improved my way of thinking, I’m sure. But enough is enough. Thank you so much everybody for all the help. It was a hell of a ride.

go forward, recursion is an hard topic and really not necessary in 99.99% of situations

the only way you will never manage is if you give up

2 Likes

Hi @33P!

I am sorry to hear that you no longer want to continue with javascript.
But I hope you would reconsider and keep going with the course.

So many people(including myself) come into this thinking if they struggle this hard then it is isn’t for them.

But most of the time that’s not true.

Struggle can be a good thing.

For example, I just spent the last week completely lost on my latest task for this part time developer gig. I poured over dozens of articles but no matter how hard I tried it just didn’t make sense.

I sent over my code expecting the lead developer to look at it and rip it to shreds.

But that didn’t happen.

He told me I wasn’t that far off and there were only a couple of places that needed changing.

So you see, I thought I knew way less than I actually did.

And I have a feeling that once you get the hang of javascript you might actually enjoy it.

But this is the hard part. All of this is new and weird.

Recursion is weird. :grin:

It is totally fine if you don’t get it the first, second, third time around.

Just take it at a pace that works for you.

Move on from now and don’t worry if this doesn’t make a whole lot of sense.
With time and practice it actually will. :grin:

2 Likes

Thank you so much @ILM and @jwilkins.oboe . I don’t know what to say. I had made a decision because the frustration was so big. I don’t think everybody has to do programming or else is a failure. I thought, maybe I can do other things. But you made me face how badly I wanted to do this. Thing is, I’m getting nuts at not being able to do things, and just when I thought I was close, I have to go at the beginning again.
To the topic here, I don’t know how to make an array out of a function. I don’t know how to make a succession of numbers, And I have thought and thought. It’s not only recursion. It’s everything. But OK, I’ll try. With your patience some day I will make out something out of this. I hope. See you tonight.

1 Like

I totally agree with that.

I just think you are really early in the learning process so it is completely normal to feel this way.

I was in your same position when I first started with programming.

I didn’t get javascript.
I didn’t understand recursion.
I struggled with algorithms.

I don’t have a STEM background. My background is in music. :grinning:

My advice would be to try it for a couple of more months and if you feel like this really isn’t for you than that’s cool. :grinning:

No one is going to consider you a failure if you decide to go another path.
We’re nice people here :grinning:

1 Like

I know, I know you’re nice people. I didn’t mean it that way and sorry if it sounded like that. But you say, two months and I’ve been around here two years. What difference would it make? I think my first decision was the right one. And I know you won’t think I’m a failure. I think I’m a Jedi hahaha, No really. This was it. Thank you again all, as I said before you’ve been really nice and it was a great experience coming here. But that was it. Thank you all.

1 Like

If you enjoy web design and comfortable with HTML and CSS, then you can stay focused on that and not worry about JavaScript. You might consider learning a bit of JavaScript to add some dynamic behavior to a web page if you are interested in that aspect. You really don’t need the JavaScript curriculum on FreeCodeCamp if you are mainly interested in making a web page better. You can start with a simpler tutorial on JavaScript or JQuery that teaches you how to add a dynamic behavior to a web page. There are many such tutorials on the Internet (e.g., W3Schools). Whatever you decide, good luck.

1 Like

@twotani Thank you so much, that’s good advice. And thank you for wishing good luck. I’ll take some time and think about it.

also, consider that there is nothing wrong in needing more time but stll needing money and so taking an unrelated job while you keep learning to code

1 Like

@ILM Thank you, I’ll take that in mind. :kissing_closed_eyes:

Hi to all. The video Quincy posted for recursion really helped me a lot to understand it! It was the first time I used code ever since I had give up in my last post.
Here’s my solution:

function rangeOfNumbers(startNum, endNum) {
  if (endNum  === startNum) {
    return [endNum];
  } else {
    let n = rangeOfNumbers(startNum, endNum -1);
    n.push(endNum);
    return n;
  }
};

Thanks to that video I’m going to return to something I really loved that is coding.
Thanks to all that tried to help in time. @JeremyLT @jwilkins.oboe @ILM I’m gonna bother you some more in the future hoho.

1 Like