Is there anyway I can reduce the repetition below? I have only shown two code blocks but there are and will be many more of the same.
I have tried using arrays and loops, but unfortunately I could not get a working example. Thank you in advance.
E1 = new Audio('audio/E1.ogg');
E1.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
A1 = new Audio('audio/A1.ogg');
A1.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
EDIT : Using Jonathan's code below, I am still wondering whether it would be possible to do the equivalent of:
(E1,A1,x,x,x).addEventListener('ended', callback, false);
// I know this bit of code doesn't work