Question: Hello i have to check Arrays(all have equal lengths) which have same elements(null in mycase) in atleast 4 consecutive positions. and return true if it has so.

Example,

```
Arr1 = ["a","","b","c","","","","","d"]; // if array is like this it should return - True
Arr1 = ["","","","","","a","b","c","d"]; // if it is like this it should return - True
Arr1 = ["p","q","","r","","","s","",""]; // if it is like this it should return - False

```

Any idea?? Please Help advise or suggest somecode in the below function so to acheive this requirement in javascript

```
function checkForSameConsecutives(arr) {

 //somecode here 

 // if condition to return true/false;
};
checkForSameConsecutives(Arr1);

```

Answer: 
You could take a closure over a counter `c` and check the value and reset if the value is truthy or add one. Then return the result of the check with the wanted length.

```js
const check = array => (c => array.some(v => (c = v ? 0 : c + 1) === 4))(0);

console.log(check(["a", "", "b", "c", "", "", "", "", "d"]));
console.log(check(["", "", "", "", "", "a", "b", "c", "d"]));
console.log(check(["p", "q", "", "r", "", "", "s", "", ""]));
```
I hope this following simple code help you

```
function checkForSameConsecutives(arr) {
            var count = 0;
            var isFound = false;
            for (var i = 1; i < arr.length; i++) {
                if (arr[i] == arr[i - 1]) {
                    count++;
                    if (count == 3) {
                        isFound = true;
                        break;
                    }
                }
            }
            return isFound;
        }

```

This is not be the best solution but it may help you to start.