조건문 Switch

Soyeon Won·2021년 10월 21일
0
post-thumbnail
const a = random();

switch (a) {
 case 0: console.log('a is 0')
 break
 case 2: console.log('a is 0')
 break
 case 4: console.log('a is 0')
 break
 default : console.log('rest....')
};
  • if문보다 코드가 깔끔하게 읽힘
  • 변수가 특정한 값으로 딱 떨어질때 사용하면 좋음
profile
Frontend

0개의 댓글