let bool = true
// with function
function toggle () {
// long way
if(bool){
bool = false
} else {
bool = true
}
// short way
bool = !bool
}
// inline way 1
bool = bool ? false : true
// inline way 2
bool = !bool
state.map((todo, index) => (index === action.index) ? {...todo, completed: !todo.completed} : todo)