是不是回文字符
作者:互联网
var isPalindrome = function(x) {
let y = []
if(x<0)return false
if(x<10)return true
let n = 10 ** Math.floor(Math.log10(x))
while(x>1 && n>1){
if(Math.floor(x/n) !== x%10)return false
x = Math.floor((x%n)/10)
n = n/100
}
return true
};
console.log(isPalindrome(12421))
标签:字符,return,floor,是不是,isPalindrome,10,x%,Math,回文 来源: https://www.cnblogs.com/MDGE/p/14155625.html