So I have this Math.random function and it occasionally returns the same object twice in a row or more when I call the function. Any ideas how to fix this?
let currentQuote;
let quoteGenerator = (response) => {
let newQuote = response[Math.floor(Math.random() * response.length)];
while (newQuote === currentQuote) {
newQuote = response[Math.floor(Math.random() * response.length)];
currentQuote = newQuote;
console.log(newQuote);
return newQuote;
}
};