title: JavaScript - Sound does not play along with random values
body: <p>I have a function that displays a random word from an array of objects, in a non-repeated way.</p>
  
  <p>My goal is to make it play a sound clip with each word (that sound would be the word's pronounciation).</p>
  
  <p>But, for some reason, I don't get any sound, in any browser, nor do any error messages show up. What can the cause be?</p>
  
  <p>This is what I am working with:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const p = document.getElementById("randomWord");
  const myWords = [
      {
         text: "alpha",
         audio: "alpha.mp3"
      },
          {
         text: "bravo",
         audio: "bravo.mp3"
      },
          {
         text: "charlie",
         audio: "charlie.mp3"
      },
          {
         text: "delta",
         audio: "delta.mp3"
      },
      {
         text: "echo",
         audio: "echo.mp3"
      }
   ];
   let remainingWords = [];
  
  function randomize() {
    if (remainingWords.length === 0) remainingWords = myWords.slice();
    let length = remainingWords.length;
    let randomIndex = Math.floor(Math.random() * length);
    const word = remainingWords[randomIndex];
    remainingWords.splice(randomIndex, 1);
    console.log(word);
    console.dir(p);
    p.textContent = word.text;
    document.getElementById("soundClip").play(word.audio);
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    &lt;audio id="soundClip"&gt;Your browser does not support the audio element.&lt;/audio&gt;
      &lt;button onclick="randomize()" type="button"&gt;Random Word&lt;/button&gt;
      &lt;p id="randomWord"&gt;&lt;/p&gt;</code></pre>
  </div>
  </div>
  </p>