Build a Random Quote Machine - Timeout on test 8 or 9

Using jQuery to make this work. Sometimes test cases 8 and 9 will work in passing. Sometimes only test case 9 will timeout. Sometimes only test case 8 will timeout.

I’m content submitting as is, since sometimes both of those test cases pass (along with all of my other ones), but I’m really curious why the test cases are failing sometimes and not others.

https://codepen.io/doicm/full/qBdPybq

Please advise. Thank you in advance.

Welcome, doicm.

I am not 100% sure, but I believe you are failing, every-now-and-again, because your use of Math.random(), means sometimes the same quote is called 2, 3, 4… times in a row.

Obviously, that implementation was not the intended purpose of this project. Ideally, you would make some sort of Ajax request to get a whole plethora of quotes - reducing the chance one will appear multiple times in a row.

Hope this helps

That makes sense. I avoided trying to use ajax because that had not been covered in any of the lessons yet, but making a sufficiently large enough database would also help the tests pass, right?

Thanks for the help!