Random Quote button

Random Quote button
0

#1

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

Any help appreciated, thanks.


#2

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

#3

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


#4

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:


#5

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


#6

Found it :

should be

}```

#7

You are too quick…


#8

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


#9

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" }];

#10

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!


#11

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

Any ideas??


#12

typo, should be:

}```