0đź‘Ť
âś…
When printing dailyDateChange
using <%= %>
it simply “prints” it as output. Consider this: You use console.log with a string element – you don’t get double quotes around it in the output.
But in your code, you want the double quotes around the values of label.
Currently you might be getting something like this:
labels: [10 April, 11 April]
While you need this:
labels: ["10 April", "11 April"]
The simplest method to do so is convert it via JSON.stringify
and use <%- %>` instead. The – tag (instead of =) does not escapes the string.
This code should work for you:
labels: <%- JSON.stringify(dailyDateChange) %>
Note that I also removed [] from around label as Stringify does that for us.
Source:stackexchange.com