JSFiddle - React, Tailwind, and code Playground

JavaScript

var val = 3;

while ((val+"").length < 3)
    val = "0" + val;

alert(val)