I am trying to passe an array from ejs to JavaScript. I can get to the values inside ejs but not from JavaScript. all the time i get undefined because the contents of the variab
I process like that to pass array from express to an EJS page: in the node.js code :
.post('/action', function(req, res) {
var arr = ["premier", "second", "troisième", "quatrieme", "cinquieme"];
res.render('page.ejs', {arr: arr});
});
And in page.ejs :
<% for(var i = 0 ; i < arr.length ; i++) { %>
<%= arr[i] %>
<% } %>