Hello, everyone! I need help with my quote machine. Sometimes my quotes, authors and colours repeat! How can i fixed this bag with Math.random? How can i exclude repeats?
const quotes = [
{quote: `"I'm not a great programmer; I'm just a good programmer with great habits."`,
author: `- Kent Beck`
}, {
quote: `"Talk is cheap. Show me the code."`,
author: `- Linus Torvalds`
}, {
quote: `"Programs must be written for people to read, and only incidentally for machines to execute."`,
author: `- Harold Abelson`
}, {
quote: `"Truth can only be found in one place: the code."`,
author: `- Robert C`
}, {
quote: `"Give a man a program, frustrate him for a day. Teach a man to program, frustrate him for a lifetime."`,
author: `- Muhammad Waseem`
}, {
quote: `"How you look at it is pretty much how you'll see it"`,
author: `- Steve Jobs`
}, {
quote: `"The most disastrous thing that you can ever learn is your first programming language."`,
author: `- Alan Kay`
}, {
quote: `"The most important property of a program is whether it accomplishes the intention of its user."`,
author: `- C.A.R. Hoare`
}, {
quote: `"I am committed to push my branch to the master."`,
author: `- Halgurd Hussein`
}, {
quote: `"Coding is not just code, that is a live thing to serve everyone!"`,
author: `- Ming Song`}
]
const colors = ['#FFC0CB]', '#DDA0DD', '#483D8B', '#F08080', '#EEE8AA', '#3CB371'];
let quoteText = document.getElementById('text');
let quoteAuthor = document.getElementById('author');
let backGround = document.getElementById('body');
function getRandom () {
let randomQuote = Math.floor(Math.random() * quotes.length);
let randomColor = Math.floor(Math.random() * colors.length);
quoteText.innerHTML = quotes[randomQuote].quote
quoteAuthor.innerHTML = quotes[randomQuote].author
backGround.style.background = colors[randomColor];
}
