How can I display array values ​​in an inline command without the & ldquo;, & quot; in JavaScript?

advertisements

I have a JavaScript where I created the 'z' array, which is the current hour and minute. I would like to print 'z' onclick, but not in an array format.

If the current time is 2:18, the output of the code below is: 2,18. What I would like is 2:18.

Thank you for your consideration and answer!

<script>
  var today = new Date();
  h = today.getHours();
  m = today.getMinutes();
  z = [h,m];
</script>  

<button onclick="document.getElementById('demo').innerHTML=z">time</button>
<p id="demo"></p>


While there are many better ways to do this, you can use: z.join(':')

I would check out http://momentjs.com/