Week 2 - REPLIT 조건문 06. isOddAndGreaterThanTwenty

grl pwr·2022년 5월 3일
0

isOddAndGreaterThanTwenty 함수를 작성하세요.

  • 숫자가 주어졌을때 주어진 숫자가 홀수이고 20보다 큰 경우에만 true를 반환합니다.
let output = isOddAndGreaterThanTwenty(13);
let output2 = isOddAndGreaterThanTwenty(27);

console.log(output); // --> false
console.log(output2); // --> true

// 내 풀이
function isOddAndGreaterThanTwenty(num) {

  if (num % 1 == 0 && num > 20) {
    return true;
  } else {
    return false;
  }
}

let output = isOddAndGreaterThanTwenty(33);

console.log(output);

module.exports = { isOddAndGreaterThanTwenty }
  • output은 true로 출력이 되는데 run tests하면 test 4의 에러. 왜 그럴까?
profile
4대륙 개발자

0개의 댓글