ReactJS-Function
< React Course Notes >< ReactJS function > Functions: const square = function(x) { return x * x; }; console.log(square(3)); // → 9 Function`s Parameters A function can have multiple parameters const roundTo = function(n, step) { let remainder = n % step; return n - remainder + (remainder < step / 2 ? 0 : step); }; console.log(roundTo(23, 10)); // → 20 or no parameters at all const makeNoise = function() { console.log("Pling!"); }; makeNoise(); // → Pling! Nested functions 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, "...