/
Charlz_Klug
/
EloquentJavaScript
Обзор
Документация
Войти
/
Charlz_Klug
/
EloquentJavaScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
03_Functions/040_Nested_Scope/nested.html
25 строк
764 B
Imil Ametov
Nested Scope
05 мар 2026, 09:33
05 мар 2026, 09:33
949de01
Код
Авторство
О чём код?
<!DOCTYPE html> <html> <body> <h2>JavaScript in Body</h2> <p id="demo"></p> <script> 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); </script> </body> </html>