I am using javascript array to randomly select source for video player. Everytime I refresh the window it randomly chooses another source from the array to play (which is I guess 'window.onload'). Instead, I want it to choose 1 source, randomly, every day at certain time (lets say 9 PM), and stick with it until next one is chosen following day.
I tried using some methods for setting date I found here, but nothing works without messing with the current script. I would appreaciate if someone could help me maintain current function, but make it daily.
const srcArray = [
"source1",
"source2",
"source3"
];
const source = document.querySelector("video");
window.onload = () => generateRandomSrc(srcArray);
function generateRandomSrc(array){
let randomNum = Math.floor(Math.random() * array.length);
source.setAttribute("src", array[randomNum]);
}