JS works inline but not in .js file– src working [duplicate]

I am running a simple table population, but when I move the js from inline html to its own file, it no longer works. Of course, my first guess was that there was an error in the reference to the .js src, but alerts in the .js file work as expected, so I know the reference is working.

const items1 = [{
    date: "10/17/2018",
    name: "john doe"
  },
  {
    date: "10/18/2018",
    name: "jane doe"
  },
];
const items2 = [{
    date: "10/17/2019",
    name: "john doe"
  },
  {
    date: "10/18/2019",
    name: "jane doe"
  },
];

function loadTableData(items) {
  const table = document.getElementById("testBody");
  items.forEach(item => {
    let row = table.insertRow();
    let date = row.insertCell(0);
    date.innerHTML = item.date;
    let name = row.insertCell(1);
    name.innerHTML = item.name;
  });
}

loadTableData(items1);
loadTableData(items2);
<!DOCTYPE html>
<html lang="en">

<head>
  <title>whiteboard</title>
  <link rel="stylesheet" type="text/css" href="whiteboard.css">
  <script type="text/javascript" src="whiteboard.js"></script>
</head>

<body>
  <table id="myTable" class="table table-borderless table-striped table-earning">
    <thead>
      <tr>
        <th>date</th>
        <th>file name</th>
      </tr>
    </thead>
    <tbody id="testBody"></tbody>
  </table>
</body>

</html>

If my src reference is working, then what else might cause an error to happen not in but in the .js file?