#TIL (April 27th, 열세번째 이야기)

Jung Hyun Kim·2020년 4월 27일
0

Introduction to Javascript (codecademy)

Codecademy Javascript 완성을 통해 새로운 용어 정리하기!


1. Conditional statement

1.1 switch/case/break/default

  • if/else if 를 대신하는 conditional statements
  • if 자리에 case
  • console.log 뒤에는 break 넣어주기
  • A switch statement can be used to simplify the process of writing multiple else if statements. The break keyword stops the remaining cases from being checked and executed in a switch statement.
let athleteFinalPosition = 'first place';

switch(athleteFinalPosition) {
  case 'first place' : 
    console.log('You get the gold medal!');
    break;
  case 'second place':
    console.log('You get the silver medal!');
    break;
  case 'third place' :
    console.log('You get the bronze medal!');
    break;
    default :
    console.log('No medal awarded.')
    break;
}

참고 url : (https://www.codecademy.com/learn/introduction-to-javascript/modules/learn-javascript-control-flow/cheatsheet)


2. function

2.1 Parameters and Arguments

parameter explained

2.2 Default Parameters

function makeShoppingList(item1 = 'milk', item2='bread', item3='eggs'){
  console.log(`Remember to buy ${item1}`);
  console.log(`Remember to buy ${item2}`);
  console.log(`Remember to buy ${item3}`);
}

2.3 Return

function monitorCount(rows,columns) {
  return rows*columns

}

  const numOfMonitors= monitorCount(5,4);

console.log(numOfMonitors);

function monitorCount(rows, columns) {
  return rows * columns;
};

function costOfMonitors(rows, columns) {
  return monitorCount(rows,columns)*200;
}

const totalCost= costOfMonitors(5,4);
console.log(totalCost);

2.4 Arrow

  • function can be rplaced with using fat arrow ()=>

profile
코린이 프론트엔드 개발자💻💛🤙🏼

0개의 댓글