How do you pass a switch statement as a function argument in Javascript?
I want to do this with Redux library:
const agendaPointsReducer = function (state = initialState, action) {
return Object.assign({}, state, switch (action.type) {
case OPEN_AGENDA_POINT: {
state.modal_is_open = true,
state.point_id = action.id
}
case CLOSE_AGENDA_POINT: {
state.modal_is_open = false
}
})
}
But I get an unexpected token error. I know this could be possible in Coffeescript, is there a way to do this in Javascript es6?