Checking "Palindrome number" is a very widespread problem. Compared to the other languages, I found it easier to solve this problem with JavaScript.
Solution:
Step 01: Convert x into string using toString().
Step 02: Split the string using split().
Step 03: Reverse the string using reverse().
Step 04: Join the string using join().
Step 05: Convert the string into number using Number().
Step 06: Check whether the number is equal to the parameter x or not.
Runtime: 330 ms
Memory: 51.1 MB
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function (x) {
return x === Number(x.toString().split("").reverse().join(""));
};
If you want me to publish more posts like this, Buy me a coffee
π YouTube Channel Link: youtube.com/channel/UCW_09Nbobf4URLkAlEo84sw
π PlayList Link: youtube.com/playlist?list=PLUnklBXn8NSefCpB..
π Connect with me (LinkedIn): linkedin.com/in/abusalehfaysal
π Follow our LinkedIn Page: linkedin.com/company/thebacklogprogrammer
π Like our Facebook page: facebook.com/thebacklogprogrammer
π Join our community (Facebook group): facebook.com/groups/5500588936676942
π Follow me at: facebook.com/AbuSalehFaysal10
π Twitter: twitter.com/AbuSalehFaysal
π Abu Saleh Faysalβs Blog: abusalehfaysal.hashnode.dev
π Hasnode: hashnode.com/@AbuSalehFaysal
π Dev Community: dev.to/abusalehfaysal
π freeCodeCamp: freecodecamp.org/abusalehfaysal
π Medium: abusalehfaysal.medium.com