title: how to export ejs object to the public directory
body: <p>I am creating a node express app and have ejs as my templating system.</p>
  
  <p>Now in my <code>new.ejs</code> file, I want to clear it out with javascripts so it will be purely html . </p>
  
  <p>I have a script inside my <code>new.ejs</code> like this. </p>
  
  <pre><code>    &lt;script&gt; 
            let amount;
  
            function calculate(){
                    let numOfPersons = Number($('#numOfPersons').val());
                    let tourPrice = Number("&lt;%= tour.price %&gt;"); //ejs object here
  
                    let totalPrice = numOfPersons * tourPrice
                    $("#total").val(totalPrice);
                    amount = totalPrice
            }   
  &lt;/script&gt;
  </code></pre>
  
  <p>Now I tried transferring it to my <code>public/javascript/calculate.js</code> file but it is saying that <code>tour is not defined</code> because the <code>&lt;%= tour %&gt;</code> is not imported inside the <code>calculate.js</code> file.</p>
  
  <p>to clean up my code, I tried this inside my <code>new.ejs</code></p>
  
  <pre><code> &lt;script src="javascripts/calculate.js"&gt;
    export default "&lt;%=  tour %&gt;" //this is the name of my object
  &lt;/script&gt;
  </code></pre>
  
  <p>and inside <code>calculate.ejs</code></p>
  
  <pre><code>import {tour} from "../../views/booking/new.js";
  
  let amount;
  
  
            function calculate(){
                    let numOfPersons = Number($('#numOfPersons').val());
                    let tourPrice = Number("&lt;%= tour.price %&gt;");
  
                    let totalPrice = numOfPersons * tourPrice
                    $("#total").val(totalPrice);
                    amount = totalPrice
            }   
  </code></pre>
  
  <p>But it is not working. I tried consulting the MDN for Import and Export and I think my syntax is correct but not working.</p>
  
  <p>What did I do wrong? Please help.</p>
  
  <p>Thanks</p>