LC-9 回文数

Easy

判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。

https://leetcode-cn.com/problems/palindrome-number/

/**
 * @param {number} x
 * @return {boolean}
 */
var isPalindrome = function(x) {
    var stringx = x.toString()
  var length = stringx.length
  var temp_list = new Array(length)
  for (var i = 0; i < length; i++) {
    temp_list[length - i - 1] = stringx[i]
  }
  var res = parseInt(temp_list.toString().replace(/,/g, ''))
  if(res == x) {
    return true
  }else {
    return false
  }
}