var str = '222222222abbccccdddddeeeeeerrrrrrrrgggggggggg44444444444444'
console.log(str.length)
let c = 0
function getMaxLength(str) {
const strLength = str.length
const result = {
code: '',
count: 0
}
let a = 0
let length = 0
for (let i = 0; i < strLength; i++) {
if (str[a] === str[i]) {
length++
console.log(length, '<-------length')
}
if (str[a] !== str[i] || i === strLength - 1) {
if (length > result.count) {
result.code = str[a]
result.count = length
}
length = 0
if (i < strLength - 1) {
a = i
i--
}
}
c++
}
return result
}
const res = getMaxLength(str)
console.log('c------------->', c)
console.log(res)
console