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

Responsive Advice Generator App with TypeScript

@Hileene

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


What are you most proud of, and what would you do differently next time?

Learning a new language is always challenging but also rewarding. For this project I wanted to start my initiation with TypeScript and it went very well. I learned the basics for now, but I can see now why it is so useful. It makes your code more robust and enforces safer coding practices.

What challenges did you encounter, and how did you overcome them?

The real challenge I had for this project was about the button, advice ID and advice text elements that were marked as "possibly null" by TypeScript although these elements were find in the DOM when only using JavaScript. Even if my JavaScript code was working perfectly, TypeScript's goal is to make sure our code is stable and handles all potential edge cases, including the possibility of elements not being found in the DOM.

Because I was sure my element will never be "null" I added the non-null assertion operator (!). I found this solution on the TypeScript documention.

Community feedback

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