I have a comma-separated string that I want to convert into an array, so I can loop through it.
Is there anything built-in to do this?
For example, I have this
let str = "January,February,March,April,May,June,July,August,September,October,November,December"
let arr = str.split(',');
it will result:
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
and if you want to convert following to:
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
this:
"January,February,March,April,May,June,July,August,September,October,November,December";
use:
str = arr.join(',')