JavaScript Function
Definition :-
In JavaScript is by using the function keyword, followed by a unique function name, a list of parameters (that might be empty), and a statement block surrounded by curly braces {}.
Syntax:-
----------------------------------------------
function functionName(parameters){
statements
}
}
Example:-
-----------------------------------
function myFunction(a, b) {
return a * b;
}
return a * b;
}
How to use this function in Script.
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
function myFunction(a, b) {
return a * b;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script>
</body>
</html>
Result:-
a function returns the result: 12