var marq = document.querySelector('marquee'); var timeStr, stockPriceDelta, stockPriceDirection; var i = 0; function updateTimestamp() { timeStr = new Date().toLocaleString(); } function updateStockPrice() { stockPriceDelta = Math.floor(Math.random() * 10000) / 100; stockPriceDirection = Math.random() < 0.5; } function renderMarquee() { updateTimestamp(); if (i % 10 === 0) updateStockPrice(); var stockPriceArrow = stockPriceDirection ? "▲" : "▼"; var stockPriceColor = stockPriceDirection ? "green" : "red"; marq.innerHTML = timeStr + " - FEM " + stockPriceArrow + " " + stockPriceDelta + ""; i++; } if (marq) { setInterval(renderMarquee, 1000); renderMarquee(); }