const billValue = 430;
const tip = billValue >= 50 && billValue <= 300 ? billValue * 0.15 : billValue * 0.2;
console.log(`The bill was ${billValue}, the tip was ${tip}, and the total value ${billValue + tip}`);
// billValue = 275, prints The bill was 275, the tip was 41.25, and the total value 316.25
// billValue = 40, prints The bill was 40, the tip was 8, and the total value 48
// billValue = 430, prints The bill was 430, the tip was 86, and the total value 516
const tip 마지막에 세미 콜론 자꾸 빼먹네 ;;
크거나 같다에서 쵸큼 헤맴
'Programming > JavaScript' 카테고리의 다른 글
Activating Strict Mode (0) | 2022.09.02 |
---|---|
Functions (0) | 2022.09.02 |
The Conditional (Ternary) Operator (0) | 2022.08.30 |
Statements and Expressions (0) | 2022.08.25 |
Coding Challenge #3 - Compare the team's average scores using if / else statements (0) | 2022.08.25 |