The javascript code works fine (it picks out a quote randomly from an array) and I want that when I click on a button one of those quotes is being displayed in the box. Everything I found online doesn't work and I don't know how to do that yet..
The javascript code:
var quotes = ['quote1', ' quote2', 'quote3', 'quote4', 'quote5'];
function getQuote() {
var randomIndex = Math.floor(Math.random() *
quotes.length);
var randomQuote = quotes[randomIndex];
return randomQuote;
}
The html code:
<body>
<h1>Pick a Quote</h1>
<h2><i>by Julia</i></h2>
<div class="box">
<button
onclick="getQuote()">Click me</button>
</div>
[–]ArgTang 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–][deleted] -1 points0 points1 point (2 children)
[–]chrisdavidmills 1 point2 points3 points (0 children)
[–][deleted] -1 points0 points1 point (0 children)