setInterval(() => { let pricesHistory = db.fetch("Velos_history"); // console.log(pricesHistory) if(pricesHistory == null) { pricesHistory = []; let currDay = parseInt(new Date().toLocaleString('en-US').split(", ")[0].split("/")[1]) for(var i = currDay; i >= currDay - 10; i--){ pricesHistory.push({ date: new Date().toLocaleString('en-US').split(", ")[0].replace(currDay.toLocaleString() , "4"), price: 300 }) } } db.set("Velos_history", pricesHistory) let currentTime = new Date().toLocaleString('en-US'); if(currentTime.includes("10:58:00 PM")){ const random = (min, max) => Math.floor(Math.random() * (max - min)) + min; let newValue = pricesHistory[pricesHistory.length - 1] + random(-10, 10); pricesHistory.push({ date: currentTime.split(", ")[0], price: newValue }) if(pricesHistory.length > 10){ pricesHistory = pricesHistory.shift(); } db.set("Valo_history", pricesHistory); db.set("Velo_value", newValue); } }, 400) })