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

Advice Generator app

@KingLyrics

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


Only thing lacking was the quotation marks. But learnt alot from this challlenge.

Community feedback

IryDev 1,580

@IryDev

Posted

Hey @KingLyrics, well done for your solution 😄

I have some advice in order to improve your solution :

  • If you want your app to display advice when the page load you can call the function getQutoe
  • Then when your page load you should see an advice instead of a lorem ipsum

JS :

const submitBtn = document.querySelector(".button");
const adviceId = document.getElementById('advice_id');
const advice =  document.getElementById('advice')

// api https://api.adviceslip.com/advice

submitBtn.addEventListener("click", () => {
  getQutoe();
});

const getQutoe = () => {
  fetch("https://api.adviceslip.com/advice")
    .then((response) => response.json())
    .then((quotes) => {
      adviceId.textContent = quotes.slip.id
      advice.textContent = quotes.slip.advice
      
    })
    .catch(error =>{
      console.log('Error fetching data:',error)
    })
};
getQuote()

I hope you'll find this helpful, BTW your solution is great 😄

Marked as helpful

1

@KingLyrics

Posted

@IryDev Excellent observation! Thank you so much!

0
IryDev 1,580

@IryDev

Posted

@KingLyrics Thank you! And no problem, don't hesitate to ask, if you have other questions

1

@KingLyrics

Posted

P.S using lorem as the place holder

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