r/learnjavascript • u/JoyShaheb_ • Jun 09 '21
Learn Callbacks, Promises, Async/Await By Making Ice Cream 🍧🍨🍦 ( Link in 1st Comment )
4
2
2
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
2
0
26
u/JoyShaheb_ Jun 09 '21
YouTube : https://youtu.be/n5ZtTO1ArWg
Article : https://www.freecodecamp.org/news/javascript-async-await-tutorial-learn-callbacks-promises-async-await-by-making-icecream/