Random Quote button

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

Any help appreciated, thanks.

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

		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 
});```

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

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 ! :persevere:

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??

Found it :

should be

}```
1 Like

You are too quick…

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

1 Like

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

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:

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

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!

2 Likes

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

Any ideas??

typo, should be:

}```
1 Like