Declaring a new function
- We declare a new function by starting with the key word "function" and "()" after the name is chosen for our function.
- We write the body of the function between the "{ }"
- We return the result thanks to the key word "return"
// Declare a simple example
function WhoRunTheWorld() {
return 'Girls';
}
//Use it
const answer = WhoRunTheWorld()
//result answer = 'Girls'
4.We can add parameters between "()"
// Declare a simple example with parameters
function add(a, b) {
return a + b;
}
//Use it
const calcul = add(5, 6)
//result : calcul = 11