DEVELOP

06. 미술관 티켓 계산 함수

/**
 * 미술관 티켓 가격을 계산해 주는 함수
 * standard, student는 카테고리에 해당하는 티켓 개수를 뜻합니다.
 */

function ticketPrice(standard, student){
  let standardPrice = 15000;
  let studentPrice = 8000; 
  let totalPrice = standard * standardPrice + student * studentPrice;

  return totalPrice;
}

console.log(ticketPrice(3,0));
console.log(ticketPrice(2,2));

 

07. 코스버거 주문 계산기 

/**
 * 주문의 합계를 계산해 주는 함수 
 * burger, hotdog, drink는 각 아이템 개수를 뜻함
 */

function orderPrice(burger, hotdog, drink){
  let burgerPrice = 6000;
  let hotdogPrice = 5000;
  let drinkPrice = 3000; 
  
  let totalPrice = burger * burgerPrice + hotdog * hotdogPrice + drink * drinkPrice;

  return totalPrice;
}

console.log(orderPrice(1,1,2));
console.log(orderPrice(0,2,2));

8. 기본 자료형

비교 연산자 : 파이썬과 비슷하지만 일치, 불일치는 등호 기호를 하나 더 쓴다.

  • 파이썬: ==, !=
  • 자바스크립트 ===, !==

===과 ==

 == 연산자는 자동으로 형 변환(type conversion)을 해준다.

/* == */
console.log('3' == 3); // true

/* === */
console.log('3' === 3); // false
profile

DEVELOP

@JUNGY00N