[3,3,3,6,4,3,1,1,1,1,5,3,1,8,2,2,3,3]
["3","3","3",6,4,3,"1","1","1","1",5,3,1,8,2,2,3,3]
const newArr = arr
.reduce((acc, n, i, a) => (
a[i - 1] !== n && acc.push([ n, 0 ]),
acc[acc.length - 1][1]++,
acc
), [])
.reduce((acc, n) => (
acc.push(...Array(n[1]).fill(n[1] > 2 ? `${n[0]}` : n[0])),
acc
), []);
const newArr = arr.map((n, i, a) => (
a[i - 1] === n && a[i - 2] === n ||
a[i + 1] === n && a[i + 2] === n ||
a[i - 1] === n && a[i + 1] === n
? `${n}`
: n
));