Hi I really new to coding in general. I iave followed instruction but its still doesnt work. PLease help.’’
Look at line 11 in script.js
quote.lenth should be quotes.length
Thanks i fixed that but when i run it, it still doesnt show any quotes?
Quote GenSimple Quote Generator
<--- script.java -->
var quotes = [
“tester is a tester”
“Chin Up”
“Churred up bro”
“dancing can be fun”
“lets play pool”
“swiming is fun”
“winning lotto will make everyone happy”
]
function newQuote() {
var randomNumber = Math.floor(Math.random() * (quotes.lenth));
document.getElementById(‘quotes’).innerHTML = quotes[randomNumber]
// body…
}
<---->
Quote GenSimple Quote Generator
I cant post my html code it just changes its self every time
There is another error in your code. Look at line 12 in script.js
The div you want to attach text to has an id of “quoteDisplay” in the html, but the div you are selecting in the function has an id of “quotes”.
Thank you but it still doesnt work. the html loads but the click button doesnt show any quotes
I knocked up an example that works on my machine.
<!DOCTYPE HTML>
<html>
<head>
<title>Random Quote Generator</title>
</head>
<body>
<h1>Random Quote Generator</h1>
<div id="quotedisplay"></div>
<button onClick="newQuote()">Get New Quote</button>
<script src="script.js"></script>
</body>
</html>
var quotes = [
"tester is a tester",
"Chin Up",
"Churred up bro",
"dancing can be fun",
"lets play pool",
"swiming is fun",
"winning lotto will make everyone happy"
];
function newQuote(){
var randomNumber = Math.floor(Math.random() * (quotes.length));
document.getElementById("quotedisplay").innerHTML = quotes[randomNumber]
}
Thank You Pethaf, your code wrks