javascript – Add music to html page according to the function output-ThrowExceptions

Exception or error:

I want my HTML page to voice out the numbers when they get displayed on the page as an output from a function. Code is as follows

<html lang="en">
  <head>
  <style>
    .home_text {
     color: #ff0026;
     font-size: 150pt;
    }
  </style>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Goplan Project Selection</title>

    <link rel="canonical" href="https://getbootstrap.com/docs/4.1/examples/sign-in/">

    <!-- Bootstrap core CSS -->
    <link href="https://getbootstrap.com/docs/4.1/dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  </head>

  <body>
  <div class="jumbotron">
  <div class="text-center">
        <img src="cissoiree.jpg" width="80px" height="80px">
    <h1>Go-Plan</h1></div></div>
    <div style="padding-top:5px;" class="text-center">
      <button class="btn-lg btn-primary" onclick="grandom()">Click!</button><br>
      <h1 class="home_text" id="demo"><h1>
    </div>
    <script> 
    var q=[2,3,1,5,4,7,6];
    var x=7;
    function grandom()
    {
    var i;
    x=q.length;
            var random;
            while(1)
            {

                random = Math.floor(Math.random()*x);
                if(random<=q.length)
                break;
            }
            if(q.length!=0){
            document.getElementById("demo").innerHTML = q[random];

            q.splice(random,1); }
     }
     </script> 
  </body>
</html>

I want my page to play audios of numbers(which I have) in the background according to the result from
q[random]
from grandom(). Chrome is my browser.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *