how to generate number in javascript zero before code example Example: js number add zero before ('0' + 11).slice(-2) // '11' ('0' + 4).slice(-2) // '04'