[javascript]
function greet(name) {
console.log("Hello, " + name + "!");
}
greet("John");
In this code, we define a function called greet
that takes a name
parameter. Inside the function, we use the console.log
method to print the greeting message to the console.
To use this function, we call it with a specific name as an argument. In this case, we are calling greet("John")
, which will output “Hello, John!” to the console.
This is just a basic example of how JavaScript functions can be implemented. The functionality can be expanded or modified based on your specific requirements.
References: