title: Using for loop and if else in cypress
body: <p>I am in a situation where I need to use for loop and If else block in <strong>cypress</strong></p>
  <p><strong>Scenario</strong>:
  Once I login to an application, I need to read an element's text which is rounded in the below screenshot.</p>
  <p>This element will appear within 20-90 seconds after I log in, when I refreshed the screen. so I need to write something like this, wait for element, if it appears reads the text and returns the value, if not wait for 10 seconds reload the page and do the process again.</p>
  <pre><code>     function waitAndreload() {
      for (let i = 0; i &lt; 10; i++) {
        cy.get(&quot;#ele&quot;).then(ele =&gt; {
          if (ele.text()) {
            return ele.text();
          } else {
            cy.wait(10000);
            cy.reload();
          }
        });
      }
    }
  </code></pre>
  <p><strong>How to write this in cypress, as cypress won't support if-else or for loops</strong></p>