Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function happyCatParking(input) {
- let days = Number(input[0]);
- let hours = Number(input[1]);
- let total = 0;
- for (let i = 1; i <= days; i++) {
- let dayPrice = 0;
- for (let j = 1; j <= hours; j++) {
- if (i % 2 === 0 && j % 2 === 1) {
- dayPrice += 2.5;
- } else if (i % 2 === 1 && j % 2 === 0) {
- dayPrice += 1.25;
- } else {
- dayPrice++;
- }
- }
- total += dayPrice;
- console.log(`Day: ${i} - ${dayPrice.toFixed(2)} leva`);
- }
- console.log(`Total: ${total.toFixed(2)} leva`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement