title: How do I set the displayName of Firebase user?
body: <p>According to the JS Auth documentation on the Firebase website, it only shows how to <em>get the displayName and how to update displayName.</em> So I tried to update it. But it is sort of not logical, because how can you update something without creating it.</p>
  
  <p>So my question here is, <em>how can I set displayName of user during registeration?</em> </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function createUser(email, password) {
      firebase.auth().createUserWithEmailAndPassword(email, password).catch(function (error) {
          error.message.replace(".", "");
          alert(error.message + " (" + error.code + ")");
          document.getElementById("password").value = "";
      });
      if (firebase.auth().currentUser != null) {
          firebase.auth().currentUser.updateProfile({
              displayName: document.getElementById("name").value
          }).then(function () {
              console.log("Updated");
          }, function (error) {
              console.log("Error happened");
          });
      }
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>I have already tried this and it has been proven not to work...</p>
  
  <p>Sincerely,
  Farouk</p>