screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> </head> <body> <p>Javascript Add Leading Zero</p> <input type="number" value="4" id="numberInput"> <button onclick="addLeadingZero()">Add Leading Zero</button> <p id="result"></p> <script> function addLeadingZero() { const number = parseInt(document.getElementById('numberInput').value); const result = number < 10 ? "0" + number : number; document.getElementById('result').innerText = result; } </script> </body> </html>