I'm currently having difficulties creating a timer. The timer sort of works, but I'm having issues converting the milliseconds into minutes/hours/seconds.
If someone could please help me and edit/guide me through what i currently have that would be amazing!
The variable inter is set to a random number. I need some code that analyzes how big the number is and decides whether to display it as milliseconds, minutes, or hours.
// JS wait function
setTimeout(() => {
function toBeRepeated(){
var inter = Math.floor(Math.random() * 90000000) + 500000;
testchannel.send("hi");
var inter1 = (inter % 60000 / 1000).toFixed(2);
setTimeout(toBeRepeated, inter);
console.log("Message sent to server 1");
console.log("Next message will be sent in " + inter1 + " seconds");
}
toBeRepeated();
}, Math.floor(Math.random() * 5000) + 2000);