【JS】【LeetCode】9.回文数

整数翻转变形

 

var isPalindrome = function(x) {
    if(x<0) return false;
    if(x<10) return true;
    var res = 0;
    var block = x
    while(x>0){
        res = (res * 10) + (x % 10)
        x = (x - (x%10)) / 10
    }
    if (res === block) {
        return true
    } else {
        return false
    }
};

  

 

posted @ 2020-07-06 14:32  xiiiiiimi  阅读(139)  评论(0编辑  收藏  举报