Design comparison
SolutionDesign
Community feedback
- @zougari47Posted over 2 years ago
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 helpful0@kirtymeenaPosted over 2 years ago@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 GitHubJoin 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