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

CSS, HTML and JS

@shaunvan119

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


Any feed back welcomed

Community feedback

P
Daveā€¢ 5,245

@dwhenson

Posted

Hi Shaun - Love job here! šŸ„³

One thing I would suggest in your JS is to add a check to ensure the API has responded correctly, and render an error message if not. This isn't too tricky, and I would just change the data variable to be something like:

  await response => response.ok ? response.json() : throw new Error("API Failed")

If you then wrap the inside of the fetchAdvice function in a try catch statement can render some fallback text in case things don't work for any reason. It's not a big deal, but thinking about how things can go wrong is a good habit to get into, something like:

const fetchAdvice = async() => {
   try {
     const res ...
    const data ....
    // rest of your code
     } 
     catch {
    document.getElementById("text").innerHTML = `"Sorry error or whatever"`
    }

Hope this helps.

Cheers šŸ‘‹

Dave

Marked as helpful

0
Shashree Samuelā€¢ 9,260

@shashreesamuel

Posted

Good job with this challenge shaunvan119. Keep up the good work.

In terms of your accessibility issues.

  • You cannot have empty headings so you can just have ""

  • Your button element needs a text to become clickable.

  • Wrap all your content between main tags to fix the other accessibility issues.

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