javascript check for identical numbers in array code example

Example: javascript check if an array has same consecutive values

const arr = ["g", "z", "z", "v" ,"b", "b", "b"];
const checkThree = arr => {
   const prev = {
      element: null,
      count: 0
   };
   for(let i = 0; i < arr.length; i++){
      const { count, element } = prev;
      if(count === 2 && element === arr[i]){
         return true;
      };
      prev.count = element === arr[i] ? count + 1 : count;
      prev.element = arr[i];
   };
   return false;
};
console.log(checkThree(arr));
console.log(checkThree(["z", "g", "z", "z"]));