Get array element by today's date - Javascript Array Operation

Javascript examples for Array Operation:Array Element

Description

Get array element by today's date

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){//w  w  w.j a  v  a 2 s .c o m
var today = new Date(),
      weekday = [ "A",
                  "B",
                  "C",
                  "D",
                  "E",
                  "F",
                  "G"
              ];
var hoy = weekday[today.getDay()];
console.log(hoy);

    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials