We can see the logic you are using to that end but could it not be simplified by shuffling the array then generating a random pick. There would be less repeats, and less logic.
The points I immediately favored were,
caching of DOM nodes
the array of objects
where and how the listener is registered
The point that struck me was the use of Title-case in what are sentences (with full stops indicating such). I’ve only just seen the JS but overall, pretty tidy job once the excess of logic is removed.
Yeah the title case was just inherited from the website I copied from, rather than writing them myself - that’s something I can add to my list of things to fix.
That’s a great suggestion for the repeats too - thanks!
I was considering just making it loop in order of index around the array, but hadn’t gotten around to deciding what to do next.
A week or so back, @jagking refined my shuffle function to make it very fast, and in JS one rather doubts it can be much improved. Go back and snag that function (just include attribution with a link to the topic). You can see how it is implemented in the example(s).
We could write a function that changes the case from Title case to Sentence case, but it would still require human inspection to isolate personal pronouns and place names. Might not be the best use of our time, though. Manual changing would get the job done quickly. Whomever thought it a good idea to use Title case might not have given it much more than a passing fancy and figured it was cool. Bad idea, in my humble view.
Aside
Seems every time one asks for the project narrative page it gets ignored. Can you please post a link to the landing page so we can view the criteria and other instructions?
That works perfectly - I’ve altered the code, and included a link to the forum. I also made it so that the array length variable resets after all of the quotes have been seen, and it starts again.
There are also a few other quotes (I removed the title case manually), and the image now has a max-height, so that the button doesn’t move too much each time.