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:
Alternative: use regexp and converting the array to a string.
var arr = [2,5,3,1,1,1,3,7,9,6,4,1,1,1,1,1,4,7,2,3,1,1,4,3]; var str = arr.join('').match(/1+/g); console.log(process ? process.sort().pop() : "No ocurrences");