Add defensive check to prevent errors when quotes list is empty

pull/1801/head
AbiAsalesh 2 days ago committed by GitHub
parent 5f220217d3
commit bbdec7dd4b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -30,7 +30,13 @@ const messages = {
};
// Utility: pick random quote
const getRandomQuote = () => quotes[Math.floor(Math.random() * quotes.length)];
const getRandomQuote = () => {
if (!Array.isArray(quotes) || quotes.length === 0) {
return "";
}
const index= MAth.floor(Math.random() * quotes.length);
return quotes[index];
};
// Utility: render quote as spans
const renderQuote = (quote) => {

Loading…
Cancel
Save