# Random Quote button

**URL:** <https://forum.freecodecamp.org/t/random-quote-button/66723>\
**Category:** General\
**Created:** [December 18, 2016, 12:10pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723 "2016-12-18T12:10:00Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesbcn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesbcn/32/64139_2.png) [@jamesbcn](https://forum.freecodecamp.org/u/jamesbcn)\
**Post date:** [December 18, 2016, 12:10pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/1 "2016-12-18T12:10:01Z")

</div>

> **[Random Quote Generator](https://codepen.io/jamesbcn/pen/mOGbXp)**
>
> ...

Hello world, could anyone tell me why my button isn’t working?

Any help appreciated, thanks.

---

<div class="post-metadata">

**Author:** ![timotheap](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/timotheap/32/26039_2.png) [@timotheap](https://forum.freecodecamp.org/u/timotheap)\
**Post date:** [December 18, 2016, 12:15pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/2 "2016-12-18T12:15:04Z")

</div>

The first thing I see when I open dev tools is that your button click isn’t a function.

````auto
		updateQuote();
	})```

It should look like this - ( I think?? Oh dear this the last time I try to help - I'm just too new, there's no helping it...try it anyway, one never knows...)

```$('#generator').click(function (){
your code here 
});```
````

---

<div class="post-metadata">

**Author:** ![jamesbcn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesbcn/32/64139_2.png) [@jamesbcn](https://forum.freecodecamp.org/u/jamesbcn)\
**Post date:** [December 18, 2016, 12:21pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/3 "2016-12-18T12:21:26Z")

</div>

> [@timotheap](#):
>
> ok like t

thanks for spotting that timo. i’ve just corrected it but the button still isn’t working…

---

<div class="post-metadata">

**Author:** ![timotheap](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/timotheap/32/26039_2.png) [@timotheap](https://forum.freecodecamp.org/u/timotheap)\
**Post date:** [December 18, 2016, 12:32pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/4 "2016-12-18T12:32:37Z")

</div>

Like I’ll stop trying to help instantly as I’m just too ignorant …

I’ve managed so far by doing bits by bits. I’d start again from the start and simply try to get to print a quote - don’t fiddle with random numbers yet.

See if you can retrieve one quote from the array.

Then see if you can retrieve it by clicking.

And then see if you can randomize the number.

That’s how I’ve done everything so far, bits by bits… Sorry again ! 😣

---

<div class="post-metadata">

**Author:** ![jamesbcn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesbcn/32/64139_2.png) [@jamesbcn](https://forum.freecodecamp.org/u/jamesbcn)\
**Post date:** [December 18, 2016, 12:36pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/5 "2016-12-18T12:36:37Z")

</div>

Thanks again.

I’ve managed to print a random quote in the console so the problem is definitely with the button itself, i just don’t know what…

Can anyone else see??

---

<div class="post-metadata">

**Author:** ![timotheap](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/timotheap/32/26039_2.png) [@timotheap](https://forum.freecodecamp.org/u/timotheap)\
**Post date:** [December 18, 2016, 12:43pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/6 "2016-12-18T12:43:16Z")

</div>

Found it :

should be

````auto
}```
````

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [December 18, 2016, 12:43pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/7 "2016-12-18T12:43:56Z")

</div>

You are too quick…

---

<div class="post-metadata">

**Author:** ![timotheap](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/timotheap/32/26039_2.png) [@timotheap](https://forum.freecodecamp.org/u/timotheap)\
**Post date:** [December 18, 2016, 12:44pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/8 "2016-12-18T12:44:27Z")

</div>

I know, I should think a bit more and stop trying where I simply can’t… lesson learned, I promise.

---

<div class="post-metadata">

**Author:** ![BenGitter](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/bengitter/32/12192_2.png) [@BenGitter](https://forum.freecodecamp.org/u/BenGitter)\
**Post date:** [December 18, 2016, 12:47pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/9 "2016-12-18T12:47:10Z")

</div>

> [@timotheap](#):
>
> I know, I should think a bit more and stop trying where I simply can’t…

I meant you were to quick to answer. 🙂 I was just about to type something like this:

> [@timotheap](#):
>
> Found it :
> 
> should be  
> $(‘#quote’).html(quotes[num]);  
> }

No seriously, you are doing great!

@jamesbcn: You tried to acces a property that doesn’t exist. It can work if you change your quotes array to somehting like this:

```auto
var quotes = [{ quote: "one", author: "1" }, 
	      { quote: "two", author: "2" },
	      { quote: "three", author: "3" }];

```

---

<div class="post-metadata">

**Author:** ![jamesbcn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesbcn/32/64139_2.png) [@jamesbcn](https://forum.freecodecamp.org/u/jamesbcn)\
**Post date:** [December 18, 2016, 12:55pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/10 "2016-12-18T12:55:34Z")

</div>

I see where I went wrong now! I am following a tutorial but trying to make a more simplified version (quote but no author.)

The tutorial has the array structured in the same way Ben set out.

Thanks again to you both!

---

<div class="post-metadata">

**Author:** ![jamesbcn](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jamesbcn/32/64139_2.png) [@jamesbcn](https://forum.freecodecamp.org/u/jamesbcn)\
**Post date:** [December 18, 2016, 1:04pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/11 "2016-12-18T13:04:34Z")

</div>

OK, I’ve tried to re-structure it and am now running into problem again…

Any ideas??

---

<div class="post-metadata">

**Author:** ![timotheap](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/timotheap/32/26039_2.png) [@timotheap](https://forum.freecodecamp.org/u/timotheap)\
**Post date:** [December 18, 2016, 1:06pm UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/12 "2016-12-18T13:06:07Z")

</div>

typo, should be:

````auto
}```
````

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [January 16, 2021, 6:10am UTC](https://forum.freecodecamp.org/t/random-quote-button/66723/13 "2021-01-16T06:10:53Z")

</div>

Closed on January 16, 2021, 6:10am UTC


