title: Javascript and Howler.js - how to choose a random sound?
body: <p>I am rather new to javascript and trying to have random selected sounds playing on mousemove. I can't get to work and would appreciate help. I am using howler.min.js to control the sound so does not wait for the sound to play to end before it plays the next sound. Here is the code: </p>
  
  <pre><code>  var soundObjects = [];
      var lastSoundTime = Date.now();
  
      c.addEventListener("mousemove",function(evt){
  
  
  
  var mx = evt.clientX - this.offsetLeft;
      var my = evt.clientY - this.offsetTop;
      //console.log("clicked at x:" + mx + ", y:" + my);
      //
      circles.push(makeMovingCircle(mx, my));
  
      var now = Date.now();
      var elapsed = now - lastSoundTime;
      console.log(elapsed);
      if (elapsed &lt; 250) {
          return
      }
  
      lastSoundTime = now;
  
      new Howl({
  
          var sounds = ['splash.mp3', 
              'splash.ogg', 
              'splash1.mp3', 
              'splash1.ogg', 
              'splash2.mp3', 
              'splash2.ogg', 
              'splash3.mp3', 
              'splash3.ogg', 
              'splash4.mp3', 
              'splash4.ogg', 
              'splash5.mp3', 
              'splash5.ogg'];
  
        var soundFile = sounds[Math.floor(Math.random()*sounds.length)];
  }
      }).play();
  </code></pre>