JSFiddle - React, Tailwind, and code Playground

by shrenuj

HTML

<!DOCTYPE html>
<html>
 <head>
  <script>
    function calc(){
    var num1 = document.getElementById("in1").value;
    
    document.getElementsByTagName("p")[0].innerHTML = "Dear " + num1 + ", Let's make everything you have read so far  a reality." ;
  }
  

Date.prototype.toShortFormat = function() {

    var month_names =["Jan","Feb","Mar",
                      "Apr","May","Jun",
                      "Jul","Aug","Sep",
                      "Oct","Nov","Dec"];
    
    var day = this.getDate();
    var month_index = this.getMonth();
    var year = this.getFullYear();
    
    return "" + day + "-" + month_names[month_index] + "-" + year;
}

// Now any Date object can be declared 
var today = new Date();


// and it can represent itself in the custom format defined above.
console.log(today.toShortFormat());    // 10-Jun-2018

  </script>
  

  
  
 </head>
 <body>
<h1></h1>
  <input id="in1" type="variable"/>
 
  <button onclick="calc()">Calculate</button>
  <p id="demo"></p>
  <script>
document.getElementById("demo").innerHTML = 5 + 6;
</script>

  <p></p>
 </body>
</html>