function formAnswer() {
  auth.onAuthStateChanged(function(user) {
    if (user) {
      console.log(`Authenticated user`);
      displayAnswer(user);
    }
    else {
      // direct unauthenticated user to login
      location.pathname = `auth.html`;
    }
  });
}

async function displayAnswer(user) {
  const userDoc = db.collection("users").doc(user.uid);
  let userData = await userDoc.get();
  const textElem = document.getElementById("text-entry-1");
  const data = userData.data();

  if (!data) {
    alert("Could not retrieve answers at this time");
  }
  else {
    textElem.innerHTML = data === null ? "" : data.ref01_text_entry_box_1;
  }
}
