diff --git a/typescript/9-Palindrom-Number.ts b/typescript/9-Palindrom-Number.ts new file mode 100644 index 000000000..21e789afc --- /dev/null +++ b/typescript/9-Palindrom-Number.ts @@ -0,0 +1,13 @@ +var isPalindrome = (x: number) => { + // Creates array from int characters + // 121 -> [1,2,1] + let arr = Array.from(String(x), Number); + + // Uses two pointer + for (let i = 0; i < arr.length; i++) { + if (arr[i] !== arr[arr.length - 1 - i]) { + return false; + } + } + return true; +}; \ No newline at end of file
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: