Created
January 7, 2016 11:22
-
-
Save MladenMladenov/4bed8ed8e6ff1aff86c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcSupply(age, maxAge, food, foodPerDay){ | |
var ageF = age; | |
var maxAgeF = maxAge; | |
var foodF = food; | |
var foodPerDayF = foodPerDay; | |
var year = 365; | |
var yearsAhead = maxAgeF - ageF; | |
var daysAhead = yearsAhead * year; | |
var totalFood = daysAhead*foodPerDay; | |
console.log(totalFood +"kg of "+ foodF+ " would be enough until I am "+maxAgeF+" years old."); | |
} | |
calcSupply(38,118,"chocolate",0.5); | |
calcSupply(20,87,"fruits",2); | |
calcSupply(16,102,"nuts",1.1); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment