Q:

Write a JavaScript program to check two given integer values and return true if one of the number is 15 or if their sum or difference is 15

0

Write a JavaScript program to check two given integer values and return true if one of the number is 15 or if their sum or difference is 15.

All Answers

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

function test_number(x, y) {
    return (x === 15 || y === 15 || x + y === 15 || Math.abs(x - y) === 15);
}

console.log(test_number(15, 9));
console.log(test_number(25, 15));
console.log(test_number(7, 8));
console.log(test_number(25, 10));
console.log(test_number(5, 9));
console.log(test_number(7, 9));
console.log(test_number(9, 25));

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