Sunday, April 18, 2021

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


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

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));

No comments:

14 May 2021 Current Affairs