Advertisement
Guest User

7. The Lifetime Supply Calculator

a guest
Jul 23rd, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function calcSupply(value) {
  2.     var age = value[0],
  3.         maxAge = value[1],
  4.         foodPerDay = value[2];
  5.  
  6.     var result = (maxAge - age) * 365 * foodPerDay;
  7.     return result + 'kg of chocolate would be enough until I am ' + maxAge + 'years old.';
  8. }
  9.  
  10. console.log(calcSupply([38, 118, 0.5]));
  11. console.log(calcSupply([20, 87, 2]));
  12. console.log(calcSupply([16, 102, 1.1]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement