Function Parameters
Functions can take in external information in the form of variables or directly through function parameters
. They are specified inside the parenthesis after the function name. Multiple parameters can be separated by commas.
Function parameters are given a variable name inside the parenthesis during function declaration. The desired values are passed when the function call is invoked. Below code block demonstrate some examples of specifying function parameters and calling functions with parameters.
xxxxxxxxxx
11
function func1(name){
console.log("Hello I am " + name)
}
function sum(a, b, c){
d = a + b + c
console.log("Sum of a, b, and c is: " + d)
}
func1("Beth")
sum(2, 3, 4)
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment