Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function computerRoom(input) {
- let month = input[0];
- let hours = Number(input[1]);
- let people = Number(input[2]);
- let time = input[3];
- let price = 0;
- if (month === "march" || month === "april" || month === "may") {
- if (time === "day") {
- price = 10.5;
- } else {
- price = 8.4;
- }
- } else {
- if (time === "day") {
- price = 12.6;
- } else {
- price = 10.2;
- }
- }
- if (people >= 4) {
- price *= 0.9;
- }
- if (hours >= 5) {
- price /= 2;
- }
- let total = price * hours * people;
- console.log(`Price per person for one hour: ${price.toFixed(2)}`)
- console.log(`Total cost of the visit: ${total.toFixed(2)}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement