![H CODING HIRE Problem Statement Coding Area 1 function characterCount Cinput) var counts = {}; The function takes a string and returns a map with the character counts. The keys to the map are the characters, the value is the number of times it occurs in the string for(var i-0;i<input.length;i++) input, charAt(i); 4 var char = if(counts[char] > 1) counts[char] += 1; 7 else counts[char] 1; = 10 return counts; Add a Failing Test Case Test Cases test input output Add Case input expected output actual output ab](https://d2vlcm61l7u1fs.cloudfront.net/media%2F8fe%2F8fe0d405-dc32-4853-ab83-2f855ba00113%2FphpyAazIw.png)
I demand succor solving this investigation. It proper has a bug and I confused-talk confront it.
The office takes a string and avail a map with the quality counts. The keys to the map are the qualitys, the compute is the enumerate of times it occurs in the string. office qualityCount(input) |{ var counts = {}: control(var i = 0;i 1) counts[char] + = 1: else counts[char] = 1: } render counts: }
It succeed entertain a fall extinguished arrange if you communicate an inarrange love this
“aab”
ie it succeed communicate the extinguishedarrange love this
{“a” : 1,”b” : 1}
so it is the crime result
expected { “a” : 2, “b” : 1}
and too there are more circumstances ie it succeed frequently communicate 1 as extinguishedput
it is attributable to the mood in the if() within the control loop
if(counts[char] > 1)
it succeed render sham at the circumstance when counts[char] =1
so dissimilate it as if(counts[char] > = 1)
then it succeed be fine
so if you communicate inarrange love
“aaaabbcccdd”
it succeed communicate { “a” : 1, “b” : 1, “c” :1, “d” : 1}