Replit.JavaScript 조건문-9.isEitherEvenAndLessThan9

younghyun·2021년 12월 29일
0

Assignment

isEitherEvenAndLessThan9 함수를 작성하세요.

  • 함수의 인자로 숫자 두 개가 주어졌을때 함수는 2가지 조건을 검사합니다.
  • 우선 두 숫자 중 적어도 하나가 짝수인지 확인합니다.
  • 그리고 두 숫자 모두 9보다 작은지를 확인합니다.
  • 두 조건을 모두 만족하는 경우만 true를 반환합니다.

    let output = isEitherEvenAndLessThan9(2, 4);
    console.log(output); // --> true

    let output = isEitherEvenAndLessThan9(72, 2);
    console.log(output); // --> false
// Assignment - 다음 함수 안에 코드를 구현하세요
function isEitherEvenAndLessThan9(num1, num2) {
  if ( num1 % 2 == 0 || num2 % 2 == 0){
    if ( num1 < 9 && num2 < 9){
      return true
    } else {
      return false
    }
  } else {
    return false
  }
}

let number = isEitherEvenAndLessThan9(4, 11)

console.log(number);

module.exports = { isEitherEvenAndLessThan9 }
profile
선명한 기억보다 흐릿한 메모

0개의 댓글