JavaScript Program to find the sum of even digits of a number
In this program, You will learn how to find the sum of even digits of a number in JavaScript.
while (Condition) {
Statement
Increment/Decrement
}
Example: How to find the sum of even digits of a number in JavaScript
let num = parseInt(prompt("Enter a number:"));
let sum = 0
while (num > 0) {
r = num % 10;
if (r % 2 == 0) {
sum = sum + r;
}
num = parseInt(num / 10);
}
console.log("Sum of even digits of a number:" + sum);
Output:
Enter a number:> 2345
Sum of even digits of a number:6