# Inconsistent click events with random quote generator

**URL:** <https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450>\
**Category:** General\
**Created:** [March 17, 2017, 12:57am UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450 "2017-03-17T00:57:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alightedlamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alightedlamp/32/63336_2.png) [@alightedlamp](https://forum.freecodecamp.org/u/alightedlamp)\
**Post date:** [March 17, 2017, 12:57am UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450/1 "2017-03-17T00:57:47Z")

</div>

Hey all, this is my first post here. I’ve made it through to the intermediate projects and built my random quote generator as a simple app with a relatively rudimentary implementation of modules. All is well, except sometimes when I click for a new quote or click to share, nothing happens. Does anyone know why that might be? If you care to see it, it’s posted here:  
[https://alightedlamp.github.io/fcc-quote-generator/](https://alightedlamp.github.io/fcc-quote-generator/)

And the code is here:  
[https://github.com/alightedlamp/fcc-quote-generator](https://github.com/alightedlamp/fcc-quote-generator)

Any feedback or thoughts would be much appreciated!

---

<div class="post-metadata">

**Author:** ![gunhoo93](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/gunhoo93/32/87162_2.png) [@gunhoo93](https://forum.freecodecamp.org/u/gunhoo93)\
**Post date:** [March 17, 2017, 1:32am UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450/2 "2017-03-17T01:32:03Z")

</div>

Your random number computation doesn’t have guard against repeat. Hence, sometimes it will give same number on consecutive trials which creates illusion of malfunction.  
Click event handler is attached to ‘a’ tag. As a result, clicking outside of the icon doesn’t trigger any event.

---

<div class="post-metadata">

**Author:** ![alightedlamp](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/alightedlamp/32/63336_2.png) [@alightedlamp](https://forum.freecodecamp.org/u/alightedlamp)\
**Post date:** [March 17, 2017, 2:39am UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450/3 "2017-03-17T02:39:32Z")

</div>

Thanks! I had noticed that there was the possibility of repeats and the next thing I wanted to do was to prevent that possibility, but didn’t realize that would be related to a click event in this way. I thought it was a different problem since I could generate a new quote, then click the twitter share button and it not respond.

---

<div class="post-metadata">

**Author:** ![renebitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/renebitter/32/68615_2.png) [@renebitter](https://forum.freecodecamp.org/u/renebitter)\
**Post date:** [October 17, 2017, 4:27pm UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450/4 "2017-10-17T16:27:42Z")

</div>

Hi there,  
I also thought at first that there was a problem with the button, but than realized that my Math.random() was actually giving me the same number again. Since I only added 3 quotes to my array, that happens a lot.

I tried to write a function that would not repeat the last used random number (once!) and it worked fine. Every click gives me a different number. As soon as I integrate it with the whole “Random Quote Machine” code, it stopped preventing the repeated random number/same quote.

Can someone tell my why?

Here are my pens:

Random Number Different From Last One Function:

> **[Random Number Different From Last One Function](https://codepen.io/renebitter/pen/VMVmLj)**
>
> ...

Random Quote Generator Array No Repeat:

> **[Random Quote Generator Array No Repeat](https://codepen.io/renebitter/pen/WZYGVz)**
>
> ...

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 5:25pm UTC](https://forum.freecodecamp.org/t/inconsistent-click-events-with-random-quote-generator/97450/6 "2021-01-16T17:25:30Z")

</div>

Closed on January 16, 2021, 5:25pm UTC


