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?

4 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.

2 Likes

I couldn’t agree more and have to say, I learned almost nothing from this exercise.
Extreme frustration, guesswork and eventual resignation, simply copying a solution from other users just to get this over with.

It feels like there is just not enough knowledge at this point to be able to solve this and the given “examples” & “hints” aren’t really helping either.

It would be great if there were a few simple examples isolating how Promises work before throwing so many unknowns with callbacks, different errors being thrown, API this and that & how to handle 15 other things, while trying to figure out the syntax of the Promises themselves.

Please help eager learners to ease into this already confusing topic a bit more with an additional, easier exercise or at least less cryptic examples/hints.

Here’s hoping I come back to this in a while and actually understanding what I’m doing :laughing:

1 Like

I’m also really struggling with this. I understand the concept of asynchronous programming, and (I think) understand the basic free step of the exercise. But I’m completely stumped with the batch step. I’m assuming it somehow involves Promise.all() but I don’t understand how to use it here.

I’ve watched/read tutorials about promises but it hasn’t helped in understanding how to use them in this specific context. It feels like there are way too many moving parts to try and understand on top of trying to learn about Promises themselves. Definitely second the idea of a simpler exercise to introduce promises as a concept.

Hey @jpekblue,

I also struggled a lot with this exercise. Mentorship really helped me work through the exercise and get a better understanding. I’d be happy to mentor you on this! Feel free to open a mentoring request and send me a private mentoring link :slight_smile:

The same for you @Knallkopp, if you feel like giving it another go!

Cheers,

Alex.

let me know if you continue struggling with this exercise. will be a pleasure to study this with you.

https://twitter.com/JoshWComeau/status/1785002770069606683

We’ll see what this entails once it drops

1 Like

I haven’t seen the catch() defined for his Promise.

1 Like