Skip to content

Commit

Permalink
- Easy peasy
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Aug 4, 2024
1 parent 978cb66 commit 20ce396
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions _002_palindrome.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function(x) {
const thisString = x.toString();
const xLength = thisString.length;
const mid = Math.floor(xLength/2);

for(let i = 0; i < mid; i++){
if(thisString[i] !== thisString[xLength-i-1]) return false;
}

return true;
};

0 comments on commit 20ce396

Please sign in to comment.