0

How to convert a comma separated string to an array in JavaScript?

Use split function:

var str = "January,February,March,April,May,June,July,August,September,October,November,December";

console.log(str.split(",")); // ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
RUN
add comment
Suggest a different solution or add another example