title: EJS variable always returns zero in Javascript code
body: <p>I have an .EJS file and the following code is written in it:</p>
  <pre><code>&lt;% var sensor_data=0 %&gt;
  
  &lt;%   var client = mqtt.connect('mqtt://io.adafruit.com',
  {
      username: &quot;**********&quot;,
      password: &quot;**********&quot;,
  }
  ) 
  
  client.on(&quot;connect&quot;,function(){
      console.log(&quot;connected&quot;);
  }
  )
  
  
  var topic = `${client.options.username}/f/sensor`;
  
  client.subscribe(topic, function(err){
  
      if(!err)
      console.log(&quot;subscribed&quot;);
  });
  
  
  client.on(&quot;message&quot;,function(topic,message){
  
      var sensor_msg = message.toString();
      sensor_data = parseInt(sensor_msg, 10)
      console.log(sensor_data);   //printing correct value
     
  });
  
  %&gt;
  
  
  
  &lt;script&gt;
  
  function updateGauges()
  {
      gauge1.value = &lt;%= sensor_data %&gt;; //something is wrong here
      console.log(&lt;%= sensor_data %&gt;);
  }
  
  
  
  gauge1 = new RadialGauge({ renderTo: 'gauge1',
      width: 250,
      height: 250,
      units: '[units]', 
      title: &quot;Sensor 1&quot;,
  }).draw();
  
  
  
  setInterval(updateGauges, 500);
  
  &lt;/script&gt;
  
  </code></pre>
  <p>I'm trying to assign value of sensor_data variable(EJS variable) to gauge1.value variable (JS variable) in the updateGauges() function but it always assign and prints zero. However, console.log(sensor_data) statement in the message receiving function is printing the correct value.</p>
  <p>I have tried:</p>
  <ol>
  <li>JSON.stringify</li>
  <li>&lt;%= sensor_data %&gt;</li>
  </ol>
  <p>but it still doesn't print or assign correct value in the script section.</p>