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