diff --git a/4-typing-game/solution/index.js b/4-typing-game/solution/index.js index 55a4f3922..b9902deae 100644 --- a/4-typing-game/solution/index.js +++ b/4-typing-game/solution/index.js @@ -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) => {