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