-4
I created this function random
, but as I’m still learning JS... I’m confused.
This code causes the above variables to appear in mode Random. But how do I get them to appear normal one by one without being Random...?
(function() {
var quotes = [
{
text: " apenas <span class='text-primary'><strong>15 moedas.</strong></span>",
},
{
text: "evolua connosco! <i class='fas fa-heart'></i>.",
},
{
text: " Procura alugar uma casa de férias? Visite eira Vacation</span>.</a>",
},
{
text: " Compre já em <a href=''><span class='text-primary'>Comprar Moedas</span>.</a>",
}
];
function random() {
var quote = quotes[Math.floor(Math.random() * quotes.length)];
document.getElementById("quote").innerHTML =
'<i class="fas fa-graduation-cap"></i> ' + quote.text + '';
}
random(); // Executa a primeira vez.
setInterval(random, 4000);
})();
Editing
function random() {
var quote = quotes[Math.floor(Math.random() * quotes.length)];
}
for(var i = 0; i < quotes.length; i++) {
document.getElementById("quote").innerHTML = '<i class="fas fa-graduation-cap"></i> ' + quote.text + '';
}
random();
You created the function, so I assume you know what the
Math.random()
does, right? So what you need is a controlled counter, which is incremented one by one, showing the messages sequentially.– Woss
Yes I know that this function makes the count and shows in Andom, but demomento I was confused because I only wish that show sequential.
– user21312321