Skip to content

Instantly share code, notes, and snippets.

@chintamanand
Created June 28, 2017 05:00
Show Gist options
  • Save chintamanand/3bc0a0ed5ba366908f37967641b80367 to your computer and use it in GitHub Desktop.
Save chintamanand/3bc0a0ed5ba366908f37967641b80367 to your computer and use it in GitHub Desktop.
reversenumber // source https://jsbin.com/zucudo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>reversenumber</title>
<script>
function gets()
{
var limit = document.getElementById("limit").value;
reverse(limit);
}
function reverse(limit)
{
var revers=0;
limit = Number(limit);
while (limit != 0)
{
revers = revers * 10;
revers = revers+ limit%10;
limit = Math.floor(limit/10);
}
alert("Reversed number is"+revers);
}
</script>
</head>
<body>
<h3>Enter the number:</h3>
<input type="text" id="limit" />
<button onclick="gets()" >Print </button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment