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