Beginner here, so my problem is only the last function in the let videos = [] array works. The other functions work as well but only when they're the last index in the array. So I've tried assigning the functions to variables and put them in the let videos = [] array and all the videos played at the same time. I have these set up to hide the other videos when 1 video is playing.
Also, I'm trying to make sure each video only plays 1 time.
function playNextVideo() {
let videos = [showVideo1(), showVideo2(), showVideo3()];
let randomVideo = Math.floor(Math.random() * videos.length);
videos.splice(randomVideo,1);
}
document.getElementById('video1').addEventListener('ended',playNextVideo(),false);
randomVideois index, so you should usereturn videos[randomVideo]and doesshowVideo1()return function?