We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent eb4b323 commit cdc2891Copy full SHA for cdc2891
1 file changed
0001 Palindrome ( L - I)/palindrome.js
@@ -1,4 +1,4 @@
1
-let n = 12321;
+let n = -12321;
2
3
if(palindrome(n)){
4
console.log( n + " is a Palindrome number");
@@ -27,6 +27,10 @@ function palindrome(n){
27
function palindromeTwoPointer(n){
28
// convert the number to string
29
let str = n.toString();
30
+ // if the number is negative, remove the negative sign from the string
31
+ if (str[0] === '-') {
32
+ return false;
33
+ }
34
// create two pointers
35
let start = 0;
36
let end = str.length - 1;
0 commit comments