Skip to content

Instantly share code, notes, and snippets.

@qodirovshohijahon
Created February 6, 2020 08:59
Show Gist options
  • Save qodirovshohijahon/1e6bc3534b962b7106c3b8dcf29d014a to your computer and use it in GitHub Desktop.
Save qodirovshohijahon/1e6bc3534b962b7106c3b8dcf29d014a to your computer and use it in GitHub Desktop.
In this example you can see solving palindrom numbers in another way.
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function(x) {
let sum = 0, n, m = x;
if (x < 0) return false;
while (x != 0 ) {
sum = sum * 10 + x % 10;;
x = Math.floor (x / 10);
}
return sum == m ? true : false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment