+ 5
Rather than manually constructing the string from the time components, you could also use the built-in formatter.
var d = new Date();
heading1.textContent = d.toLocaleTimeString('en-GB');
The default time format for en-GB locale is 24 hours, with leading zeroes.
+ 3
heading1.textContent =
String(h).padStart(2, '0') + ":" +
m + ":" + s;