How to Create a Simple Hello and Goodbye Function in JavaScript?

Estimated read time 1 min read

Here is an example to create a simple “Hello” and “Goodbye” function in JavaScript:

function sayHello(name) {
  console.log("Hello, " + name);
}

function sayGoodbye(name) {
  console.log("Goodbye, " + name);
}

sayHello("John");
sayGoodbye("John");

This code defines two functions, sayHello and sayGoodbye, which take a name parameter and log a greeting to the console. The last two lines of the code call the functions, passing in the argument "John".

You May Also Like

More From Author

+ There are no comments

Add yours

Leave a Reply