I'm building Yahtzee with React Redux. In my scores reducer I'm calculating whether or not to award the 30 points for a small straight based on the dice state. The dice state is expressed as an array and so i have to detect whether or not this array includes 1, 2, 3, 4 ... 2, 3, 4, 5 ... or 3, 4, 5, 6. What I came up with works but it looks very messy (below). Is there a cleaner way to check if these sets of values appear within an array?
setSmallStraight: (state, action) => {
if (
action.payload.includes(1)
&& action.payload.includes(2)
&& action.payload.includes(3)
&& action.payload.includes(4)
||
action.payload.includes(2)
&& action.payload.includes(3)
&& action.payload.includes(4)
&& action.payload.includes(5)
||
action.payload.includes(3)
&& action.payload.includes(4)
&& action.payload.includes(5)
&& action.payload.includes(6)
) {
state['Small Straight'] = 30
} else {state['Small Straight'] = 0}
},