Advertisement
Guest User

Untitled

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