Using JavaScript, I\'m trying to find a way to find the longest occurrence of the same number (in this case, 1) in an array.
For instance, here\'s a sample array:
Your problems:
streak
Use this:
function streak(arr) { var i, temp, streak = 1, maxStreak = 0, prevNumber, length = arr.length; for(i=1; i maxStreak) { maxStreak = streak; streak = 1; } } } return maxStreak; }
Demo