Check out example codes for "javascript loop audio list". It will help you in understanding the concepts better.

Code Example 1

let audio = new Audio();
        var playlist = this.state.sequence; // load the sequence of sounds
        audio.src = playlist[0].src; // set the source of the first file in my array; 
        // when the song ends, load the new sound
        audio.addEventListener('ended', function(){
            // increment playlist[i].src
        }, true);
        audio.loop = false;

Learn ReactJs, React Native from