Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function backToThePast(input) {
- let money = Number(input[0]);
- let lifeCycle = Number(input[1]);
- let age = 18;
- for (i = 1800; i <= lifeCycle; i++) {
- if (i % 2 === 0) {
- money = money - 12000;
- age++;
- } else {
- money = money - (12000 + 50 * age);
- age++;
- }
- }
- 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.`);
- }
- }
- backToThePast([100000.15, 1808])
Add Comment
Please, Sign In to add comment