Random quote machine, need help!

Random quote machine, need help!
0

#1

Hello everyone!

I have little problem with syntax on random quote machine project. Does anyone have idea why it shows me syntax error?

Code: http://codepen.io/piorys/pen/wWAyNk

Thank you in advance


#2

There are a few issues with how your jQuery is structured. Since you’re using jQuery, the document.getElementById can be shortened, as shown below. I changed the name of the var random to “item” just so there isn’t a readability confusion between that var and Math.random(). Lastly, you have “random” in quotes when passed to innerHTML(). It’s a variable name, so it does not require quotes.

Here is an alternative version:

$(document).ready(function() {

$("#quote-button").click(function() {
var item = quotesArr[Math.floor(Math.random() * quotesArr.length)];
$("#quote-placement").html(item);
});

});


#3

You don’t know how grateful I am for your help. There is a long way ahead of me :slight_smile: