reverse number

<html>
<body>
<script>
  var number=23781;
  var reverse=0;
  do{
      var lastDigit=number%10;
      reverse=(reverse*10)+lastDigit;
      number=number/10;
  }while(number>=1);
  alert("Thar number reversed is"+reverse);
 </script>
 </body>
 </html>

 

posted @ 2016-08-14 16:16  小菁菁爱吃番茄酱  阅读(165)  评论(0编辑  收藏  举报