Build a Random Quote Machine - The Correct Way?

:stuck_out_tongue: There’s ways to make it not awful (use regexes to break at a space, create shortened link to the quote on your page, etc). No need to listen to my suggestion, just offering a possibility for using other quotes, since you mentioned that being a problem with using a public API.

I have also build this project using API.You can even use a file with ur defined json in it and retrieve data from it.
You can review my project here.

You can also go through you tube videos of Stephen Mayeux for building random quote machine.
They are of great help.

1 Like

Your aproach to the Tweet button help me understand it, thanks.

I used innerHTML to pull paragraph elements in a hidden div and an array with set color #'s and a math.random effect inside of it. I applied this ID to the body tag, which creates the random color effect. I know ajax might have been a better way to access the quotes but a hidden div with paragraphs does the trick. There are only six quotes by the way. Any suggestions for improvement are appreciated. Thanks.

You can review my work here:

but it will make your content static .Using apis make sense

1 Like

Thank you so much. It really helped me. Wish you a very happy new year :slight_smile:

1 Like

Does anyone know how to implement react js in codepen?

Can you link your codepen?

You may not have included the react scripts/CDN

https://codepen.io/karano/pen/PBgawE

You might want to create a new thread for this.

It looks like you’re having an issue with the axios library, i’m not sure how to fix it. Also your getRandomQuote() function is undefined

Fine, thank you. I will look for it

It is something to do with axios.

I commented out the axios stuff and it compiles, you can see here.
https://codepen.io/cameleater/pen/VBJpPN?editors=0011

You can first create an object of some quotes and once you have it all rendering properly try working on pulling quotes from an API.

Yeah, it was an issue with the axios library. Thanks