Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function guineaPig(inp) {
- let input = inp.map(Number);
- let food = input[0] * 1000;
- let hay = input[1] * 1000;
- let cover = input[2] * 1000;
- let pigWeight = input[3] * 1000;
- for (let i = 1; i <= 30; i++) {
- food -= 300;
- if (food <= 0 || hay <= 0 || cover <= 0) {
- break;
- }
- if (i % 2 === 0) {
- hay = hay - food * 0.05;
- }
- if (i % 3 === 0) {
- cover -= pigWeight / 3;
- }
- }
- if (food > 0 && hay > 0 && cover > 0) {
- console.log(`Everything is fine! Puppy is happy! Food: ${(food / 1000).toFixed(2)}, Hay: ${(hay / 1000).toFixed(2)}, Cover: ${(cover / 1000).toFixed(2)}.`);
- } else {
- console.log(`Merry must go to the pet store!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment