I am trying to join the values of an object/associative array to make changes to my code easier but I can't figure out how to properly join them. Here is my code:
$( document ).on( "click", ".taskstatus a", function ( event ) {
event.preventDefault();
classes = {
'OPEN': 'state_open',
'COMPLETED': 'state_completed',
'SKIPPED': 'state_skipped',
'REJECTED': 'state_rejected'
};
joinedClasses = classes.map(function(value, key){ return key; }).join(' ');
state = $(this).data('state');
taskID = $(this).closest('.task').attr('id').replace( 'task_', '' );
// Update checkbox icon
$(this).closest('.taskwrap').find('.taskcheckbox').data( 'icon', $(this).data('icon') );
// Update task class
alert( joinedClasses );
$(this).closest('.task').removeClass( joinedClasses ).addClass( classes[state] );
});
This code breaks at the map function since it doesn't see it as an array, whats the best way to accomplish joining the values of class so that they look like this: "state_open state_completed state_skipped state_rejected"?