A JavaScript function is a set of statements that take inputs, process them, and return an output. It helps perform specific tasks or calculations, making the code more reusable and efficient.
Syntax
function functionName(Parameter1, Parameter2, ..) {
// Function body
}Example
Below is a sample program that illustrates the working of functions in JavaScript:
function greetUser(username) {
<<<<<<< HEAD
console.log(`Hello ${username}, welcome to Coding75`);
=======
console.log(`Hello ${username}, welcome to Coding75!`);
>>>>>>> 6c9caef (content Overview Complete)
}
greetUser('Admin');Output
<<<<<<< HEAD
Hello Admin, welcome to Coding75
=======
Hello Admin, welcome to Coding75!
>>>>>>> 6c9caef (content Overview Complete)