Q:

Write a JavaScript program to check whether a given integer is within 20 of 100 or 400

0

Write a JavaScript program to check whether a given integer is within 20 of 100 or 400.

All Answers

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

function testhundred(x) {
  return ((Math.abs(100 - x) <= 20) ||
	 (Math.abs(400 - x) <= 20));
}

console.log(testhundred(10));
console.log(testhundred(90));
console.log(testhundred(99));
console.log(testhundred(199));
console.log(testhundred(200));

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