Palindrome Number LeetCode Cheat Sheet Javascript Solution

This LeetCode Challenge is really similar to the “reverse integer challenge” with a little spin. This time we want to return a boolean value.

The Palindrome challenge is in the easy category and is a good start for understanding more challenging algorithms. I will focus on explaining a solution that works and not on the O time and space complexity.

Palindrome Number Challenge

“Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.” (LeetCode)

1.Let create a reversed version of x

a)Convert the number into a string ex 565 became “565”

b)Split the string ex “565” became “5”,”6",”5"

c)Reverse the split string ex “5”,”6",”5" became “5”,”6",”5"

d)Join method will create a string by concatenating the elements of the array ex “5”,”6",”5" became “565” is x.toString is strictly equal to its reversed version.

When using a comparison sign the result would be a boolean value, true or false.

In our case, it will return true




Lifelong learner , Full Stack Software Engineer.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store