Skip to content

Commit cdc2891

Browse files
added some logic
1 parent eb4b323 commit cdc2891

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

0001 Palindrome ( L - I)/palindrome.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
let n = 12321;
1+
let n = -12321;
22

33
if(palindrome(n)){
44
console.log( n + " is a Palindrome number");
@@ -27,6 +27,10 @@ function palindrome(n){
2727
function palindromeTwoPointer(n){
2828
// convert the number to string
2929
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+
}
3034
// create two pointers
3135
let start = 0;
3236
let end = str.length - 1;

0 commit comments

Comments
 (0)