title: How to Initialise class properties using inquirer js?
body: <pre><code>class Example {
      constructor(id) {
          this.id = this.getId();
      }
      getId() {
          inquirer
              .prompt({
                  message: &quot;Enter id?&quot;,
                  type: &quot;input&quot;,
                  name: &quot;employeesId&quot;,
              })
              .then((answer) =&gt; (this.id = answer.employeesId));
      }
  }
  
  const testExample = new Example();
  testExample.getId()
  console.log(testExample.id); // &lt;-- expected to log the id after user has entered it, instead returns undefined
  </code></pre>
  <p>So I'm new to OOP and just would like to understand why this won't work, any help would be appreciated.</p>
  <p>A work around with explanation would also be highly appreciated.</p>
  <p>Thanks in advance.</p>