title: Cannot set a variable's value inside cypress command cy.get() to use outside the command
body: <p>I'm setting a <code>pin</code> variable, updating it in <code>cy.get()</code> and then trying to use it after the <code>cy.get()</code> - it doesn't allow me to do this. </p>
  
  <p>I've also read here that this is not possible: <a href="https://docs.cypress.io/guides/core-concepts/variables-and-aliases.html#Return-Values" rel="noreferrer">https://docs.cypress.io/guides/core-concepts/variables-and-aliases.html#Return-Values</a>. </p>
  
  <p>I really need to use this variable in order to be able to login: it's a generated PIN and I need to use it when logging in. </p>
  
  <pre><code>var pin = ""
  cy.get('.pin-field').invoke('text').then((text1) =&gt; {
      pin = text1; //assign text1 value to global pin variable, does not work
  
      cy.log(text1) // this works and logs the value of text1
  })
  
  cy.log(pin) //this just logs an empty
  </code></pre>