Q:

Write a JavaScript program to check a number from three given numbers where two numbers are equal, find the third one

0

Write a JavaScript program to check a number from three given numbers where two numbers are equal, find the third one.

All Answers

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

function find_third_number(x, y, z) {
   if((x!==y) && (x!==z) && (y!==z))
    return "Three numbers are unequal.";
	if(x==y) return z;
	if(x==z) return y;
	return x;
}

console.log(find_third_number(1,2,2))
console.log(find_third_number(1,1,2))
console.log(find_third_number(1,2,3))

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