I think the reply is surely simple but I am lock on it :/ I want to send a array of array from my server.js to my view.ejs and I need it at the array format. here my code :
in server.js
.get('/map', async function(req, res) {
let areaCoordinates= await getCoordinates();
res.render('map.ejs', {token: tokenMapbox, areaCoordinates: areaCoordinates});
})
The array of arrays is areaCoordinates (lets say it's [[[1,2],[3,4]],[[5,6],[7,8]]] but longer and with a length which can change, the length of the array in array also can change only the array in array in array is always 2 (x and y coordinates))
in view.ejs
<script>
/* some stuff */
let areaCoord_1="<%= areaCoordinates[1] %>";
let areaCoord_2= "<%= areaCoordinates[2] %>";
/* some stuff */
</script>
my problem is for exemple areaCoord_1 = "1,2,3,4" and areaCoord_2="5,6,7,8" when I would need [[1,2],[3,4]] and [[5,6],[7,8]]
I also try in view.ejs
let areaCoord_1=[]
"<%= for (coord of areaCoordinates[1]) { %>"
areaCoord_1.push(coord);
"<%= } %>"
but then i have a syntax error.
does someone have a solution ?
(I think about transforming the string in array and every 2 element making another array for remake the array of array but probably there is cleanier solution and less ressource consuming)
Important point is that I really need an array and not a string in outpout