본문 바로가기

Python_WEB/JavaScript

[freecodecamp]JavaScript 미만 연산자

반응형

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

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

그렇지 않으면 false를 반환합니다.

같음 연산자와 마찬가지로보다 작음 연산자는 비교하는 동안 데이터 유형을 변환합니다.

 

예>

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

 

Q>

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

2. testLessThan (0)은 "Under 25"를 반환해야합니다.

3. testLessThan (24)는 "Under 25"를 반환해야합니다.

4. testLessThan (25)는 "Under 55"를 반환해야합니다.

5. testLessThan (54)은 "Under 55"를 반환해야합니다.

6. testLessThan (55)는 "55 이상"을 반환해야합니다.

7. testLessThan (99)는 "55 이상"을 반환해야합니다.

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

 

A>

function testLessThan(val) {
    if (val < 25) {
        // Change this line
        return 'Under 25';
    }

    if (val < 55) {
        // Change this line
        return 'Under 55';
    }

    return '55 or Over';
}

console.log(testLessThan(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

 

반응형