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
'FRONTEND > JavaScript' 카테고리의 다른 글
[코드잇 - 모던 자바스크립트] 03. 함수 다루기 (0) | 2022.11.16 |
---|---|
[코드잇 - 모던 자바스크립트] 02. 자바스크립트의 동작 원리 (0) | 2022.11.16 |
[코드잇 - 모던 자바스크립트] 01. 모던 자바스크립트 이해하기 (0) | 2022.11.16 |
[코드잇 - 파이썬 개발자를 위한 자바스크립트 기초] 3. 심화 자료형 (0) | 2022.11.16 |
[코드잇 - 파이썬 개발자를 위한 자바스크립트 기초] 2. 제어문 (0) | 2022.11.15 |