JavaScript functions are used to perform operations. We can call JavaScript function many times to reuse the code.
Advantage of JavaScript function
There are mainly two advantages of JavaScript functions.
The syntax of declaring function is given below.
function functionName([arg1, arg2, ...argN])
{
//code to be executed
}
JavaScript Functions can have 0 or more arguments.
<!DOCTYPE html>
<html>
<head>
<title>JavaScript</title>
<script>
function hello() {
document.write("Hello Everybody");
}
function yahoo() {
document.write("Yahoo Baba");
}
hello();
document.write("</br>");
yahoo();
document.write("</br>");
hello();
document.write("</br>");
hello();
</script>
</head>
<body>
</body>
</html>