I created a code for a random quote generator and now I want to create something similar, but with images this time. I am looking to add a feature on my page where it can recommend a book by displaying its cover image when a button is clicked.
For the previous quote generator, I used the following code:
HTML:
<div class="quotes">
<h1 class="quote-generator">Simple Quote Generator</h1>
<div id="quoteDisplay"></div>
<button onclick="newQuote()" class="button-quote">New Quote</button>
<script src="./js/quotes.js"></script>
</div>
JavaScript
var quotes = [
'One must always be careful of books,<br>and what is inside them,<br>for words have the power to change us.<br>—Cassandra Clare',
'Only the very weak-minded refuse to be<br>influenced by literature and poetry.<br>—Cassandra Clare',
// more quotes here
]
function newQuote() {
var randomNumber = Math.floor(Math.random() * (quotes.length));
document.getElementById('quoteDisplay').innerHTML = quotes[randomNumber];
}
Now, I am wondering how I can modify the quotes in the variable "quotes" to display as images instead?