So I have this JS array variable with string values. This generates quotes at each button click. I noticed that after going through all quotes, there's one last click that outputs nothing. So I have to click the button a second time to generate quotes again. Any idea as if it's possible to solve this?
Much thanks
<div id="enQuoteDisplay">
<!--English quotes display here-->
</div>
<div align="left">
<button onclick="newQuoteEn()">Next</button>
</div>
<script src="translator.js"></script>
#enQuoteDisplay {
position: absolute;
top: 400%;
left: 5%;
font-size: 30px;
}
button {
position: absolute;
left: 5%;
top: 1000%;
}
var quotesEn = [
"Hello, how are you?",
"I love you.",
"When does the bus come?",
"Where is the nearest market?",
"What time is it?",
"I don't/didn't understand.",
"I need/want to go home.",
"Dinner was delicious.",
"Congratulations!",
"Happy New Year!",
"I am cold.",
"The battery is dead.",
"We are going to the beach.",
"Let's dance!",
"I sent you an email.",
"You look good."
]
function newQuoteEn() {
var randomNumber = Math.floor(Math.random() * (quotesEn.length));
document.getElementById('enQuoteDisplay').innerHTML = quotesEn[randomNumber];
}
One quote at each button click with no interruption.