본문 바로가기

Python_WEB/JavaScript

[freecodecamp]JavaScript 이하 연산자

반응형

작거나 같음 연산자 (<=)는 두 숫자의 값을 비교합니다.

왼쪽에있는 숫자가 오른쪽에있는 숫자보다 작거나 같으면 true를 반환합니다.

왼쪽의 숫자가 오른쪽의 숫자보다 크면 false를 반환합니다.

같음 연산자와 같이 작거나 같음은 데이터 유형을 변환합니다.

 

예>

4   <= 5  // true
'7' <= 7  // true
5   <= 5  // true
3   <= 2  // false
'8' <= 4  // false

 

Q>

1. return 문이 의미가 있도록 표시된 줄에 작거나 같음 연산자를 추가합니다.

2. testLessOrEqual (0)은 "Smaller Than or Equal to 12"를 반환해야합니다.

3. testLessOrEqual (11)은 "Smaller Than or Equal to 12"를 반환해야합니다.

4. testLessOrEqual (12)는 "Smaller Than or Equal to 12"를 반환해야합니다.

5. testLessOrEqual (23)은 "Smaller Than or Equal to 24"를 반환해야합니다.

6. testLessOrEqual (24)는 "Smaller Than or Equal to 24"를 반환해야합니다.

7. testLessOrEqual (25)는 "More Than 24"를 반환해야합니다.

8. testLessOrEqual (55)는 "More Than 24"를 반환해야합니다.

9. <= 연산자를 두 번 이상 사용해야합니다.

 

A>

function testLessOrEqual(val) {
    if (val <= 12) {
        // Change this line
        return 'Smaller Than or Equal to 12';
    }

    if (val <= 24) {
        // Change this line
        return 'Smaller Than or Equal to 24';
    }

    return 'More Than 24';
}

console.log(testLessOrEqual(10));

 

https://www.freecodecamp.org/

 

freeCodeCamp.org

Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.

www.freecodecamp.org

 

반응형