Javascript program to check last digit of numbers are equal

In this Javascript program to check the last digit of given numbers are same or not. To get the last number of given numbers we will get the module of each number with 10, so it will return last digit of the given number as remainder.

Let's write the program

// Prompt user to enter 3 numbers 
const x = parseInt(prompt('Enter first number: '));
const y = parseInt(prompt('Enter second number: '));
const z = parseInt(prompt('Enter third number: '));
// Obtain last digit from user inputs
const result1 = x % 10;
const result2 = y % 10;
const result3 = z % 10;
// Compare last digits
if(result1 == result2 && result1 == result3) {
console.log(`${x}, ${y} and ${z} have the same last digit.`);
else {
console.log(`${x}, ${y} and ${z} have different last digit.`);



Enter first number: 199

Enter second  number: 129 

Enter third number:99

199 , 129 and 99 have the same last digit.


Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns