Users can select checkboxes for each day of the week.
Below is an example JS object:
{"mon":true,"tue":true,"wed":true,"thu":false,"fri":false,"sat":false,"sun":false}
The goal is to convert these selections into a string of comma-separated values, with Monday as 0 and so on. For example, if only Sunday is selected, the string would be
7
A conversion attempt has been made using the following code:
var b = days;
days = days.map(function (a) {
return b.indexOf(a);
});