What Is a Function Body in Programming?
A function’s body is where you place a sequence of statements you want to execute.
Syntax of a JavaScript Function Body
Function Body Examples
Below are examples of how we use the function body.
How to define a function with three statements in its body
In the snippet above, the function’s body contains three statements that the computer will execute whenever the function gets invoked.
Note: console.log()
is a method we use to log (write) messages to a web console.
How to define a function with two statements in its body
In the snippet above, the function’s body contains two statements that the computer will execute whenever the function gets invoked.