adspace


how to print the most continuously repeated character in a
string?

Answer Posted / Sanjit Choudhary

To find and print the most frequently occurring character in a string using JavaScript, you can use the following code: `let str = 'your string'; let charFreq = {}; for (let i=0; i<str.length; i++){ if(charFreq[str[i]]){ charFreq[str[i]]++;} else { charFreq[str[i]] = 1;} } let maxChar = ''; let maxCount = 0; for (const [key, value] of Object.entries(charFreq)) { if(value > maxCount){ maxCount = value; maxChar = key;}} console.log(maxChar);`

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

iwant to join testing in mind q.is there any new batch will start for testing? i heard that nageswarao is not in mindq he started another institute which one is better? i also want to know the fee deails & duration of the course.

3044


i need some list of names in handicapped acheivers. where can i found? if anyone know please mail me janarthanan25@yahoo.co.in i need 5 persons of names in disabled acheivers. it is very urgent. please help me

2104


plz mail me the latest topics for discriptive papers or latest topics for bank clerical exams

1891


What is valley, Playa, Catchment area, Basin ? please describe with picture.

1981


i perapering for ugc net in computer science can any one tell me selabus for it & tell me somthing about it

2565


Dear sir, Corporation bank has announced notification to apply for clerk post{IBPS}. They are going to test language proficiency test I want to know what questions they have asked previously at corp bank clerk interview and please mail me karthik.keya87@gmail.com

2187


describe yourself...

2116


plz send me last 10 years bank clerk papers for union bank clerk for preparation. thank u..plz hurry up..its urgent

2208


Please tell me the reference for absence of yeast and mold for(drinking)feed water for pharmaceutical use. If anybody have link please post.

2220


Please send me NIC entrance for DIO and DIA question Sample paper at bedajithome@gmail.com.

3017


when will sbi clerical final result out?????? interview held in the months of april and may 2010

2522


please i have been given a project on optical networking hardware,i have done all i could but i could'nt find the information i wanted,please can u help me,i need to submit it in 6hours time today.please try and help me out.

2111


what is the syllabus for group2 exams? please answer this one

2077


what is the dates for group2 exams?

2049


what kind of jobs will you be doing in the next one year, two years or five years?

1318