I created this function random
, but as I'm learning JS I still ... I'm confused.
This code causes above variables to appear in random mode. But how do I appear normal 1 by 1 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();