1

I have an Integer input that I want to output as 2 digits.

Besides using padStart()

String(month).padStart(2, '0')

My current solution:

`${String(month).length > 1 ? '' : '0'}${month}`

Is there a more elegant/another way to do the same?

Jee Mok
  • 6,157
  • 8
  • 47
  • 80

0 Answers0