[Solved] I don’t understand the if{} statement


The if in your code is prefixing the value of i with a zero if it is less than 10

1 becomes 01
2 becomes 02
10 stays as 10
etc

This is so that cosmetically, the hour & minute are displayed as expected.


The formatting is a bit misleading – better written as

 function checkTime(i){
       if (i < 10) {
          i = "0" + i;
       }
       return i;
  }

solved I don’t understand the if{} statement