[TIL] 8/8

Rami·2024년 8월 8일

TodayILearn

목록 보기
2/61

1

'\n'은 각 문자의 뒤에 줄바꿈 문자를 추가합니다. 이를 백틱을 사용해 템플릿 리터럴로 바꿔도 동일하게 작동합니다:

let b = a.map(x => `${x}\n`); // 템플릿 리터럴 사용

2 if else구문

        console.log(`${n} is even`)
    } else {
        console.log(`${n} is odd`)
    }

3 삼항연산자

console.log( 
   	n%2 === 0 ? `${n} is even` : `${n} is odd` 
   );
profile
YOLO

0개의 댓글