Nested Scope, No results?

In the Eloquent JS Doc, Chapter 3, Nested Scope…I don’t understand this example. Is there an answer to this. It does not compute anything, it seems…?

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”);

i think it does.basically there was just a function bound to a an example:if you type hummus(3);it should execute the code and console.log the list of ingredients you need for 3 people.
but im struggeling myself here to understand the details:)

1 Like

thanks! - I’ll have to play around with that later on

1 Like