title: value of a function in JavaScript(protractor) returns as undefined
body: <p>im using protractor to retrieve a text.</p>
  
  <p>one of the function is</p>
  
  <pre><code>//get the Impersonation ID
  this.getUserSessionID = function(){
      //get whole text
      UserImpersonateTextElement.getText().then(function(text) {
          var tempText = text;
          var startString = 'session ID is ';
          var sessionID = tempText.substring(tempText.lastIndexOf(startString)+startString.length,tempText.length);
          console.log('sessionID is:'+sessionID);
          return sessionID;
      });
  };
  </code></pre>
  
  <p>and im calling the function in another js(where i imported the above js) file</p>
  
  <pre><code>var getUserImpersonationID = ImpersonationSuccessPage.getUserSessionID();
  </code></pre>
  
  <p>and when i try </p>
  
  <pre><code>console.log('User Impersonation ID is:'+getUserImpersonationID);
  </code></pre>
  
  <p>i get undefined as the value.</p>
  
  <p>but the  <code>console.log('sessionID is:'+sessionID);</code> in the function displays proper value.</p>
  
  <p>Can anyone suggest what im doing wrong here?</p>