I have an array of numbers. I need to find the maximum number of consecutive 1s in the array.

```
var arr = [1, 1, 3, 2, 3, 1, 1, 1];

const maxOne = (arr) => {
  for (var i = 0; i < arr.length; i++) {
    let count = 0;
    let result = 0;
    if (arr[i] ==1) {
      count += 1;
      result = Math.max(result, count);
    } else {
      count = 0
    }
  return result
  }
}

console.log(maxOne(arr));

```

desired output: `3`

my output : `1`

I am not sure where I am going wrong