function bakeCake(ingredient){ | |
// Code that adds the ingredient to the cake batter | |
console.log(ingredient+ ' cake : add ' +ingredient+ ' to the batter'); | |
function ovenTemperature(temperature, time){ | |
// Code that sets the right temperature for baking the cake | |
console.log('Set the oven temperature to ' +temperature+' and ready to bake the '+ingredient+' cake for ' +time+ ' minutes'); | |
} | |
return ovenTemperature; | |
} | |
// We are preparing two cakes : let’s first add the ingredients and we’ll see for the rest of the recipe later. | |
var chocolateCake = bakeCake('chocolate'); | |
var carrotCake = bakeCake('carrot'); | |
// Ok now we have put the ingredients in the batter, let the batter rest and go fetch the temperature and baking time for these types of cakes. | |
chocolateCake(250, 70); | |
carrotCake(200, 90); | |
// Prints : | |
"chocolate cake : add chocolate to the batter" | |
"carrot cake : add carrot to the batter" | |
"Set the oven temperature to 250 and ready to bake the chocolate cake for 70 minutes" | |
"Set the oven temperature to 200 and ready to bake the carrot cake for 90 minutes" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment