I need some help with the random quote machine

Before going to my problem. I have a question. Do you necessarily need to do the same thing as the example solution(https://codepen.io/freeCodeCamp/full/qRZeGZ) provided does to get a new quote?

The reason I am asking for this is because I used and array that I made out of some quotes I found on the internet.
After I ran the test on my code. It said that after clicking the new-quote button it should fetch a new quote and the author for that quote, which I already did this using a random element from the array of quotes I was talking earlier. So I am figuring that I should do the same thing as the provided solution.

The only other reason I can think of that this doesn’t work is the reason I used react rather than jQuery.

my project - https://codepen.io/Rayish/full/MWmmENG

Challenge: Build a Random Quote Machine

Link to the challenge:

No.

What happening is, there is a script error.

Every time the #new-quote button is clicked, this error pop out:
image

And that error is coming from here:
image

Where the scope is not defined.

Try it out! If there is still error, open:

This

You made the function recursive. Which mean every time the old quote and new quote are same, the function will be called again. Where the random generator generate the same number every time, your app crushes.
image

I am not giving you answer, try out yourself! :smile:

Hope This Help!

1 Like

Thanks. I found a solution to this by cutting the previous quote out the array and then taking a random quote. :grinning: