JavaScript Tutorials
26.9K subscribers
5 links
This channel will serve you all the codes and programs of JS language
Download Telegram
40. Write a JavaScript program to check from two given integers whether one of them is 8 or their sum or difference is 8.

function check8(x, y) {
if (x == 8 || y == 8) {
return true;
}

if (x + y == 8 || Math.abs(x - y) == 8)
{
return true;
}

return false;
}

console.log(check8(7, 8));
console.log(check8(16, 8));
console.log(check8(24, 32));
console.log(check8(17, 18));
Lockdown extended till 3rd May 2020

Be safe and Stay at home
42. Write a JavaScript program to check whether three given numbers are increasing in strict mode or in soft mode.

function number_order(x, y, z ) {
if ( y > x && z > y)
{
return "strict mode";
}
else if(z > y)
return "Soft mode";
else
return "Undefinded";
}

console.log(number_order(10,15,31));
console.log(number_order(24,22,31));
console.log(number_order(50,21,15));
43. Write a JavaScript program to check from three given numbers (non negative integers) that two or all of them have the same rightmost digit.

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));
44. Write a JavaScript program to check from three given integers that whether a number is greater than or equal to 20 and less than one of the others.

function lessby20_others(x, y, z)
{
return (x >= 20 && (x < y || x < z)) ||
(y >= 20 && (y < x || y < z)) ||
(z >= 20 && (z < y || z < x));
}
console.log(lessby20_others(23, 45, 10));
console.log(lessby20_others(23, 23, 10));
console.log(lessby20_others(21, 66, 75));
45. 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.

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));
46. Write a JavaScript program to check two given non-negative integers that whether one of the number (not both) is multiple of 7 or 11.

function valCheck (a, b) {
if (!((a % 7 == 0 || a % 11 == 0) && (b % 7 == 0 || b % 11 == 0))) {
return ((a % 7 == 0 || a % 11 == 0) || (b % 7 == 0 || b % 11 == 0));
}
else
return false;
}
console.log(valCheck(14, 21));
console.log(valCheck(14, 20));
console.log(valCheck(16, 20));