I’m currently working on the Random Quote Machine project in React. I took a ‘step by step’ approach to try to refresh and solidify what I have learnt so far.
I made the html & CCS mark up to start with. I then begun to add React. As I am not familiar with APIs I chose to start with an object of 5 quotes which would display in order when clicked on the button. I seem to be stuck on this step.
Could anyone point me in the right direction?
Here’s a link to what I have so far:
You’ll need to iterate through your object.
Here is a quick and dirty example I made. I changed your object to an array of objects, I think that may simplify it.
Thank you, that’s really helpful!
I thought of bunch of different ways of iterating through the object but couldn’t get it to work. It appears that all I needed was to change the object itself.
for random you might try…
var num = Math.floor(Math.random() * (boxQuotes.length - 1) + 1);
and then do…
but you may need to make sure that the old random num != the new one?
If you need some more help with the Random Quote Machine, I have a series of videos that describes how I went about it: https://www.youtube.com/watch?v=3QngsWA9IEE&list=PL3cz80ehFCandt8KYS1NRzfjjIqpeu5c4&index=3
Thank you, also super helpful. I was able to finally complete the project!
I forked yours so i can one day try out React stuff
here is my simple JQ one …
Chuck Norris Jokes