Struggling with Promises – 'Translation Service' exercise

This is the very last module on the JS track syllabus. Suddenly I just don’t follow. It feels like a big jump from the other modules with nothing leading you into this last one – that’s how it feels to me at least

I keep coming back to this thinking maybe now I can tackle it, but nope. I’m not really sure how to proceed. Or where exactly I’m stuck. I’m clearly missing something.

Does anyone have any advice?

3 Likes

Hey @MikeHud,

asynchronous programming is hard to get your head around the first time. When my programming mentor back in the day introduced me to concurrency and parallelism he said: “You need to be very strong now, until now you’ve lived in a perfect (synchronous) world, but now I’m gonna ruin it for you by showing you that the world isn’t actually that simple and perfect.” (or something along those lines anyways) :D

It’s kind of hard to give you specific recommendations, if you’re not sure yourself where you are stuck. Did you write any code that you could share or are you not even sure where and how to start?

One general advise that I can give is the following procedure:

  1. Write some code
  2. Explain to yourself (or your rubber duck) what you expect to happen
  3. See if the output matches your expectation
  4. Try to find out why it behaves differently from your expectation / where your mental model was wrong

Don’t be afraid to write some code that you’re sure won’t work, get started and iterate.

To understand Promises I can recommend watching some Youtube video(s), imo it’s just easier to see asynchrony in action than to read about it. I personally like the way Traversy Media explains things, so that’s my go to Javascript channel:

Note that this is a crash course, for a tutorial that moves more slowly you can check out the video from freecodecamp or just search for “Promises Javascript” and choose one that you like: Asynchronous JavaScript Course (Async/Await, Promises, Callbacks) - YouTube

Maybe after watching a video the concept of Promises is more clear, or at least you can pinpoint at which point you get lost?

3 Likes

I agree, I’m in the same boat. Made it through to this last module, and it really does seem like a leap in complexity. I understand all the concepts broadly after doing the reading, but there seems to be gap in this ‘learning’ exercise that basically doesn’t (for me so far) really help you to understand where to even begin. Matters of syntax, when and how one can access which properties, just a clear basic example how to get this Promises engine started with the given problem, they’re all missing.

Now, I imagine I could resolve all these issues for myself simply by checking out the published community solutions of others – but I really don’t want to have to do that… at least not at first. I want to have an honest stab at doing it on my own terms by understanding it from first principles before resorting to that, but for the moment I feel completely lost. The confidence I had been building throughout the otherwise excellent JS stream is kind of all draining out of me now.

Don’t feel discouraged and congratulations on making it this far. I will be looking at these exercises Spring 2023 and update here once they are revised.

Completely agree. I felt the last exercise was particularly difficult with given information. The hint for the last exercise is:

Instead of nesting .then and/or .catch, .then takes a second argument which catches everything before (earlier in the chain), ignoring errors in the first argument of .then.

So I tried very hard to come up with a solution that follows the format Promise.then(arg1, arg2), but every solution I see follows the format of Promise.catch.then. I wasn’t aware reversing then/catch was even an option or what effect it has.

I don’t know if I’m completely misunderstanding something here, but I’m having trouble seeing how anyone could ever arrive at that solution.

1 Like