function sayHello() {
  document.querySelector('h1').textContent = 'Hello World!';
}

document.querySelector('button').addEventListener('click', sayHello);
Preview

Hints

const heading = document.querySelector('h1');
const btn = document.querySelector('button');

function sayHello() {
  heading.textContent = 'Hello World!';
}

btn.addEventListener('click', sayHello);

Overskrift