Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function backToThePast(input) {
- let i = 0;
- let money = Number(input[i++]);
- let year = Number(input[i++]);
- let age = 17;
- for (let j = 1800; j <= year; j++) {
- if (j % 2 === 0) {
- age++;
- money -= 12000;
- } else {
- age++;
- money -= 12000 + age * 50;
- }
- }
- if (money >= 0) {
- console.log(`Yes! He will live a carefree life and will have ${money.toFixed(2)} dollars left.`);
- } else {
- console.log(`He will need ${Math.abs(money).toFixed(2)} dollars to survive.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement