unlucky1: a 1 then a 3 near either end?
A 1 immediately followed by a 3 is an "unlucky" 1. Return true if the array contains an unlucky 1 in the first 2 or last 2 positions. Step through unlucky1: three places are checked — starting at index 0, at index 1, and at nums.length - 2. Each check first makes sure the array is long enough.