- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check whether sum of digit of a number is Palindrome - JavaScript
We are required to write a JavaScript function that takes in a number, sums its digits and checks whether that sum is a Palindrome number or not. The function should return true if the sum is Palindrome, false otherwise.
For example, if the number is 697, then the sum of its digit will be 22, which indeed, is a Palindrome number.
Therefore, our function should return true for 697.
Example
Following is the code −
const num = 697; const sumDigit = (num, sum = 0) => { if(num){ return sumDigit(Math.floor(num / 10), sum + (num % 10)); }; return sum; }; const isPalindrome = num => { const revered = +String(num) .split("") .reverse() .join(""); return revered === num; }; const isSumPalindrome = num => isPalindrome(sumDigit(num)); console.log(isSumPalindrome(num));
Output
Following is the output in the console −
true
- Related Articles
- Checking whether the sum of digits of a number forms a Palindrome Number or not in JavaScript
- C++ Program to Check Whether a Number is Palindrome or Not
- Haskell Program To Check Whether The Input Number Is A Palindrome
- Digit sum upto a number of digits of a number in JavaScript
- Program to check whether number is a sum of powers of three in Python
- Write a Golang program to check whether a given number is a palindrome or not
- Palindrome in Python: How to check a number is palindrome?
- Check whether a number is a Fibonacci number or not JavaScript
- Negative number digit sum in JavaScript
- Check if binary representation of a number is palindrome in Python
- Reduce sum of digits recursively down to a one-digit number JavaScript
- Check if a number is Palindrome in C++
- Check whether sum of digits at odd places of a number is divisible by K in Python
- 8085 program to check whether the given 16 bit number is palindrome or not
- Haskell Program To Check Whether The Input String Is A Palindrome

Advertisements