title: getting error - Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first
body: <p>I want to play audio as an alert but I'm getting an error like "Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.</p>
  
  <p>HTML Code:</p>
  
  <pre><code>&lt;audio id="alarm" src="alarm.mp3"&gt;&lt;/audio&gt;
  </code></pre>
  
  <p>JavaScript Code:</p>
  
  <pre><code>function alarm() {
      var value = document.getElementById("rvoltage").innerHTML;
      if (value &gt; 230) {
          document.getElementById('alarm').play();
      }
  }
  </code></pre>