← Back to Forum

revercing

Posted on December 10, 2024, 12:45 pm


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>reversng in html using js</title>
</head>
<body>
<input type="number" placeholder="enter a number" id="num">
<button onclick="reverse()" id="res">check</button>
<input type="number" placeholder="enter a number" id="output">

<hr>

<script>
function reverse()
{
var input=12345;
var output=0;
var rem;

while(input!=0)
{
rem= input%10;
output = rem + output*10
input = parseInt(input/10);
}
{
document.getElementById("output").value =input;
document.getElementById("res").value =output;

}
}
</script>
</body>
</html>


Add a Reply


Replies (0)

No replies yet. Be the first to reply!