Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function puppy(input) {
- let food = Number(input[0]) * 1000;
- let hay = Number(input[1]) * 1000;
- let cover = Number(input[2]) * 1000;
- let weight = Number(input[3]) * 1000;
- let IsNeedsFullfiled = true;
- for (let i = 1; i <= 30; i++) {
- food -= 300;
- if (food <= 0) {
- IsNeedsFullfiled = false;
- break;
- }
- if (i % 2 == 0) {
- hay = hay - (food * 0.05);
- if (hay <= 0) {
- IsNeedsFullfiled = false;
- break;
- }
- }
- if (i % 3 == 0) {
- cover = cover - (weight / 3);
- if (cover <= 0) {
- IsNeedsFullfiled = false;
- break;
- }
- }
- }
- if (IsNeedsFullfiled) {
- 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