title: Interweave EJS and Javascript variables inside <% tags
body: <p>I need to use a Javascript variable (defined in the front-end) in some EJS code, as follows:</p>
  
  <pre><code>var selected = 1;
  &lt;% for (var i=0; i &lt; supplies.length; i++) { %&gt;
      if (i == selected) {
          console.log(supplies);    
      }
  &lt;% } %&gt;
  </code></pre>
  
  <p>I'm using EJS, Express.js and socket.io. I could convert the Javascript variable to an EJS variable by sending a message to my Node.js server instance, but that's kind of silly... Is there a way to use Javascript variables inside EJS?</p>
  
  <p>EDIT:
  I want to access supplies, a javascript array, after the user selected an item from a drop down menu. When he selects this item, a javascript function with the above code needs to access some EJS. That's why I need to use a normal Javascript variable in EJS. </p>