I have a question about line 5 of this little Javascript program. With the parentheses/parameters on line 5, audioNumber
is inside/next to the inner parentheses because audioNumber
is a parameter of .indexOf
. Whereas the number 1
on this line is a parameter of .splice
so it is inside the outer parentheses. Is this a correct understanding of why audioNumber
and 1
are where they are on line 5?
function playAudio(audioNumber) {
var audio = document.getElementById('sound' + audioNumber);
audio.play();
var nonPlaying = [1, 2, 3, 4, 5, 6, 7];
nonPlaying.splice(notPlaying.indexOf(audioNumber), 1); // line 5
nonPlaying.forEach(function(id) {
document.getElementById('sound' + id).pause();
document.getElementById('sound' + id).currentTime = 0;
});
};