diff --git a/eloquentjavascript/functions.js b/eloquentjavascript/functions.js index 0a7b887..ec78d69 100644 --- a/eloquentjavascript/functions.js +++ b/eloquentjavascript/functions.js @@ -1,3 +1,21 @@ -const square = function(x) { +const square = function (x) { return x * x; -} \ No newline at end of file +} + +const hummus = function (factor) { + const ingredient = function (amount, unit, name) { + let ingredientAmount = amount * factor; + if (ingredientAmount > 1) { + unit += "s"; + } + console.log(`${ingredientAmount} ${unit} ${name}`); + + }; + ingredient(1, "can", "chickpeas"); + ingredient(0.25, "cup", "tahini"); + ingredient(0.25, "cup", "lemon juice"); + ingredient(1, "clove", "garlic"); + ingredient(2, "tablespoon", "olive oil"); + ingredient(0.5, "teaspoon", "cumin"); +}; +hummus(10); \ No newline at end of file diff --git a/eloquentjavascript/loopingatriangle.html b/eloquentjavascript/loopingatriangle.html index 0a6db78..a239753 100644 --- a/eloquentjavascript/loopingatriangle.html +++ b/eloquentjavascript/loopingatriangle.html @@ -13,9 +13,6 @@ function start(){ triangle += "#" document.getElementById('triangle').innerHTML += `