Advertisement
Neri0817

back to the past *edited*

Apr 20th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function backToThePast(input) {
  2.     let inheritance = Number(input[0]);
  3.     let endYear = Number(input[1]);
  4.  
  5.     let age = 17;
  6.  
  7.     for (let i = 1800; i <= endYear; i++) {
  8.         age++;
  9.         if (i % 2 === 0) {
  10.             inheritance -= 12000;
  11.         } else if (i % 2 === 1) {
  12.             inheritance -= 12000 + 50 * age;
  13.         }
  14.     }
  15.  
  16.     if (inheritance >= 0) {
  17.         console.log(
  18.             `Yes! He will live a carefree life and will have ${(inheritance).toFixed(2)} dollars left.`);
  19.     } else {
  20.         console.log(`${Math.abs(inheritance).toFixed(2)}`);
  21.     }
  22. }
  23. backToThePast([100000.15, 1808])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement