Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Random advice generator using API

Hum Brunoβ€’ 230

@humbruno

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


This project was a great way to put into practice my JavaScript skills by handling promises.

Async functions are incredibly simple yet powerful to use, and certainly a good solution to "callback hell"!

I also tried the same solution using .then and .catch without the async functions which achieved the same results. I am not yet sure when to choose one over the other. Definitely something to do more research on!

Community feedback

Luis Castilloβ€’ 380

@lipe11

Posted

Hi, I can leave some thoughts on async/await vs promises. I wondered the same thing when I was learning it.

Both are equivalent, async/await is just syntactic sugar over promises. At the end I think is which one you think reads better.

For simple calls, the promise/then syntax i think reads a little better, but in a more complex scenario with multiple related calls, thats where the async/await syntax shines.

Fireship has an excellent video on the subject.

Marked as helpful

0
T
Chamuβ€’ 13,110

@ChamuMutezva

Posted

Greetings Hum. Nice work so far, well doneπŸ™Œ. One area that i picked up that needs improvement is the use of a div as an interactive element. Try navigating the site using a keyboard, you will notice that the div does not get focus, which means that keyboard users will not be able to use the site. A button can solve that issue with no extra coding.

Happy coding

Marked as helpful

0
Prabhash Ranjanβ€’ 2,540

@besttlookk

Posted

hi, About your question about when to use async-await or .then()

When ever you get promise in return you can you both. Both are one and the same thing. Both does same thigg behind the scene. Async-await added later to make code more redeable and clean. Below are some addition benefit of using async await.

  1. To avoid "callback hell". If you have a asyn work one after the another. Your code will be nested very deep using ".then" syntax. Which can easily be avoided using "async/await" syntax.

  2. To have single error catching function: In case of .then, you have to use "catch" for every ".then". But with "async/await" you just have to do once using "try/catch" block.

async function(){
  try{
     const response1 = await fetch("");
     const response2 = await fetch("");
    const response3 = await fetch("");
   }catch(error){
     console.log(error)
   }
}

I am no expert , just shared my experiece. I hope it helped.

Good Luck.

#happyCoding

Marked as helpful

0
Shashree Samuelβ€’ 9,260

@shashreesamuel

Posted

Hey good job completing this challenge

Keep up the good work

Your solution looks great however I think that your card title is a bit too small and should be bigger

I hope this helps

Cheers Happy coding πŸ‘

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord