Reverse decimal digits in javascript

后端 未结 14 947
灰色年华
灰色年华 2021-02-05 16:24

How do I reverse the digits of a number using bitwise?

input:

x = 123; 

output:

x = 321; 
14条回答
  •  时光取名叫无心
    2021-02-05 17:11

    If you wanted to make a simple reversal:

    var x = 123;
    var y = x.toString();
    var z = y.split("").reverse().join("");
    var aa = Number(z);
    document.write(aa);
    

    http://jsfiddle.net/jasongennaro/gV39e/

提交回复
热议问题