Create the function of the onclick attribute in the script.

<html>
<body>
  <p id="name">JohnnyG</p>
  <p id="age">25</p>
  <button onclick="generate()">Generate a username</button>
  <p id="username"></p>
  <script src="script.js"></script>
</body>
</html>
]]>

Make sure to pick generate().