Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cinema(input) {
- let screeningType = input[0]
- let rows = Number(input[1])
- let columns = Number(input[2])
- let ticketPrice = 0;
- if (screeningType === "Premiere") {
- ticketPrice = 12.00;
- } else if (screeningType === "Normal") {
- ticketPrice = 7.50;
- } else {
- ticketPrice = 5.00;
- }
- console.log(`${(rows * columns * ticketPrice).toFixed(2)} leva`);
- }
- Второ решение с тернарен оператор:
- function cinema(input) {
- let screeningType = input[0]
- let rows = Number(input[1])
- let columns = Number(input[2])
- let ticketPrice =
- screeningType === "Premiere" ? 12.00 :
- screeningType === "Normal" ? 7.50 : 5.00;
- console.log(`${(rows * columns * ticketPrice).toFixed(2)} leva`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement