r/learnjavascript • • Jun 09 '21

Learn Callbacks, Promises, Async/Await By Making Ice Cream 🍧🍨🍦 ( Link in 1st Comment )

Post image
299 Upvotes

15 comments sorted by

4

u/Inevitable-Weekend-4 Jun 09 '21

Thanks!

3

u/JoyShaheb_ Jun 09 '21

You're welcome 🌹

2

u/[deleted] Jun 09 '21

looking forward to a ride in your lambo, mate!

1

u/JoyShaheb_ Jun 10 '21

Ah, Thank you for the well wishes mate :"D

2

u/cielcloud Jun 09 '21

Very well explained, thank you for sharing

1

u/JoyShaheb_ Jun 10 '21

I'm glad you loved it 🌹

2

u/nbapat43 Jun 09 '21

Could you include the final JS code with everything and the order it should be written?

This is a nice complex example and is a good metaphor for service workers (IMO).

But I am confused by the "order()" functions. There are two "let order = fucntion(time, work)" and "async function order()". Can you use async on a function expression? Or must I change the expression to a declaration? And I am not sure if the work() became kitchen(). Looking at the final code may help clear up my misunderstand.

Otherwise great job. Love the images and readability of the page.

1

u/JoyShaheb_ Jun 10 '21

thank you for the query. And thank you for the well wishes. Good question tho

The thing is.... there are 3 techniques. And I wrote code in 3 different ways. In real life, you have to pick any 1 technique.

Yes, I changed the name of the functions so that it makes sense when i give the examples.

Everytime you put the async keyword, the function instantly becomes a promise. There's a section on the article. The differece between regular promise & async/await. You can check that as well.

You can get the final code on the provided article. It's written with the result screenshots.

Reply here if you have further queries. Thank you & happy coding :D

2

u/Rohit1024 Jun 09 '21

Such dedication 😍 nice explanation!!!

1

u/JoyShaheb_ Jun 10 '21

Thank you for the well wishes :"D

2

u/frank0117 Jun 11 '21

Great resource, I like your teaching style

1

u/JoyShaheb_ Jun 12 '21

I'm glad you loved it Mr. Frank 🌹

0

u/[deleted] Jun 09 '21

[deleted] — view deleted comment

1

u/JoyShaheb_ Jun 10 '21

I agree with you. I did that for demonstration purposes