Skip to content

我也来试试 #590

Open
Open
@DingSJi

Description

@DingSJi

const fn = function(str){
let arr = str.split("")
let obj = {}
let maxStr = "",
maxNum = 0;
arr.reduce((pre, next) => {
if(pre in obj){
if(pre == next)
obj[pre]++
}else{
obj[pre] = 1
}
return next
},arr[0])
console.log(obj)
for(let key in obj){
if(maxNum < obj[key]){
maxNum = obj[key]
maxStr = key
}
}
return ${maxStr}-${maxNum}
}

console.log(fn('aaaaaabbbba'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions