Sure, here’s a simple function in JavaScript that prints ‘Hello World’ to the console:
function sayHello() {
console.log('Hello World');
}
// call the function to print 'Hello World' to the console
sayHello();
When you run this code in a JavaScript environment like a web browser console or Node.js, it will output ‘Hello World’ to the console.
