Q:

Write a JavaScript program to check from three given numbers (non negative integers) that two or all of them have the same rightmost digit

0

Write a JavaScript program to check from three given numbers (non negative integers) that two or all of them have the same rightmost digit. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function same_last_digit(p, q, r) {
    return (p % 10 === q % 10) ||
           (p % 10 === r % 10) ||
           (q % 10 === r % 10);
           
}

console.log(same_last_digit(22,32,42));
console.log(same_last_digit(102,302,2));
console.log(same_last_digit(20,22,45));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now