My function is almost there, but I am facing an issue:
function prevTrack() {
if (playlist_index == (playlist.length - 0)) {
playlist_index = -1;
} else {
playlist_index--;
}
playlist_status.innerHTML = playlist[playlist_index];
audio.src = dir + playlist[playlist_index] + ext;
audio.play();
}
I believe the error lies in the line playlist_index = -1;
.
Could someone please advise me on how to access the last item in the array?
So it should be playlist_index = ???;