title: How to implement a for loop in Jsonata
body: <p>I am looking to convert xquery to jsonata ,</p>
  <pre><code>let $h := $at//datahistory
  for $x in 0 to (count($h))
  let p:= (if (not($h[$x]/daytoday =(‘one’, ‘two’) )) then ‘ZERO’ else $h[$x+1]/Status 
  return if(index-of($p) &gt; 0 then 0 else 1)
  </code></pre>
  <p>Any kind of assistance and help is much appreciated.</p>
  <p>Thanks in advance.</p>