Monday, 24 May 2021

WT-25

                                  

1]Write a JavaScript function that reverse a input number                                                   

<html>

<script type ="text/javascript">

function rev_num()

{

var num = prompt("Enter the number to be reveresed :", " ");

var n= num;

var rev = 0, rem;

while (n>0)

{

rem = n % 10;

rev = rev * 10 + rem ;

n = Math.floor(n/10);

}

document.write("The given number is : " +num+ " <br/> The reversed number is : " +rev+ "\n");

}

</script>

<body style="" onload="rev_num();">

<body>

</html>

2] Refer Slip 1