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

Active Generator App

kirty 380

@kirtymeena

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

Community feedback

@zougari47

Posted

Hi there👋,

you don't need to add an advice id and increment it by 1, every time the user click the button should get random advice and https://api.adviceslip.com/advice give you random advice.

I propose this solution :

const getAdvice = () => {
  fetch("https://api.adviceslip.com/advice", {
  cache: 'no-cache'
})
    .then((response) => response.json())
    .then((data) => {
      id.innerHTML = data.slip.id
      content.innerHTML = '<q>'+data.slip.advice+'</q>';
    });
};

dice.addEventListener('click',  getAdvice)

happy coding

Marked as helpful

0

kirty 380

@kirtymeena

Posted

@zougari47 Hi, Thanks for the feedback, I have updated the code and it works now.

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