my question is about a Quote generator I am working on. It's working also onload :), But I would like to omit the situation when the next onclick randomly picked quote is the same as the last shown quote. I would like it to be different. Thank You for Your hints.
this is my js code:
var quotes = [
{ text: "Memento mori",
autor: "Bractwo Męki Pańskiej" },
{
text: "Jeśli możesz sobie coś wymarzyć, możesz też to zrobić.",
autor: "Walt Disney"
},
{
text: "Wszystko jest możliwe. Niemożliwe wymaga po prostu więcej czasu.",
autor: "Dan Brown"
},
{
text: "Czerp z innych, ale nie kopiuj ich. Bądź SOBĄ",
autor: "Michel Quois"
},
{
text: "Kiedy łamiesz zasady, łam je mocno i na dobre.",
autor: "Terry Pratchett"
}
];
window.onload = function() {
quoteMachine.initialQuote()
};
var quoteMachine = {
initialQuote: function() {
var newInitialQuote = quotes[Math.floor(Math.random() * quotes.length)];
var newInitialQuoteText = newInitialQuote.text;
var newInitialQuoteAutor = newInitialQuote.autor;
document.getElementById("new-quote").innerHTML = newInitialQuoteText;
document.getElementById("autor").innerHTML = newInitialQuoteAutor;
}
};
This is the working example: https://randome-quote-machine.glitch.me
Aucun commentaire:
Enregistrer un commentaire