From c41480530995bae49794c26e8afc6423ecf28442 Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 9 Dec 2023 17:00:50 +0000 Subject: [PATCH] vault backup: 2023-12-09 17:00:50 --- .../functions and parameters.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/React/The Complete Guide Docs/functions and parameters.md b/docs/React/The Complete Guide Docs/functions and parameters.md index 980863a95..b3c598a96 100644 --- a/docs/React/The Complete Guide Docs/functions and parameters.md +++ b/docs/React/The Complete Guide Docs/functions and parameters.md @@ -17,4 +17,17 @@ function greet() { greet() // Hello World! ``` -* Functions can take parameters, +* Functions can take parameters, knows as input values +* Parameters are then available within the scope of the function +* The idea behind parameters, is that you can have one re-usable function, that can be re-used with different input values +```js +function greet(userName, message) { + console.log(`${message} ${userName}`); +} + +greet("Liam", "Hello"); +greet("Frazer", "Hello") +``` + +* You can assign default values to parameters, by adding a `=` sign +* The default value can be overridden, by simply providing a value