javascript - Sound can't be defined in if statement -


i have code this:

    var snd = [new audio("bla/blo.wav"), new audio("bla/bli.wav")]      function playsnd(x) {         if (x == 1) {snd[0].play()}         if (x == 2) {snd[1].play()}     }      playsnd(2) 

here @ "playsnd(2)" problem, play both of sounds, why???

var snd = ["bla/blo.wav", "bla/bli.wav"]  function playsnd(x) {     if (x == 1) {(new audio( snd[0] )).play()}     if (x == 2)  {(new audio( snd[1] )).play()} }  playsnd(2) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -