Trying to pass arguments from server side to client in Node.js using Express.
I am using the following command on the server side :
for (var i = 0; i < events.length; i++) 
{
    existingEvents.push(events[i]);
}
res.render('index', { locals: {existingEvents: existingEvents}});
And the following code on the client side (jade), inside a script section
var events = "";
      for (var i = 0;i < existingEvents.length;i++)
        {
             if (i == 0)
             {
                 events = "events: [{title: '" + existingEvents[i].summary +"', start: '" + existingEvents[i].start.dateTime + "',constraint: 'businessHours'}";
             }
             else
             {
                 events += ", { title: 'aaaaaaaaa', start: '2016-03-03T13:00:00',constraint: 'businessHours'}";
             }
        }events += "]";
When I debug on chrome i get the following error concerning the existingEvents:
"Uncaught ReferenceError: existingEvents is not defined".
I had a look at this post : Accessing Express.js local variables in client side JavaScript and tried various ways to accomplish it. (tried #{existingEvents} for example).
But nothing worked so far. how would you guys accomplish this? Thanks you very much for you help :)