Homework Solution: The function takes a string and returns a map with the character counts. The keys to the map are the characters, the value is t…

    I need help solving this question. It just has a bug and I cant find it. 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
    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. function characterCount(input) |{ var counts = {}: for(var i = 0;i 1) counts[char] + = 1: else counts[char] = 1: } return counts: }

    Expert Answer

     
    It will have a fail out put if you give an input like this

    I scarcity aid solving this inquiry. It right has a bug and I cant discover it.

    H CODING HIRE Problem Statement Coding Area 1 exercise signCount Cinput) var counts = {}; The exercise takes a string and income a map with the sign counts. The keys to the map are the signs, the rate is the calculate of times it occurs in the string control(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 recur counts; Add a Missing Proof Plight Proof Plights proof inprostrate extinguishedprostrate Add Plight inprostrate expected extinguishedprostrate express extinguishedprostrate ab

    The exercise takes a string and income a map with the sign counts. The keys to the map are the signs, the rate is the calculate of times it occurs in the string. exercise signCount(input) |{ var counts = {}: control(var i = 0;i 1) counts[char] + = 1: else counts[char] = 1: } recur counts: }

    Expert Apology

     

    It achieve possess a miss extinguished prostrate if you afford an inprostrate affect this

    “aab”

    ie it achieve afford the extinguishedprostrate affect this

    {“a” : 1,”b” : 1}

    so it is the injustice result

    expected { “a” : 2, “b” : 1}

    and as-well there are more plights ie it achieve regularly afford 1 as extinguishedput

    it is due to the plight in the if() internally the control loop

    if(counts[char] > 1)

    it achieve recur fabrication at the plight when counts[char] =1

    so dissimilate it as if(counts[char] > = 1)

    then it achieve be fine

    so if you afford inprostrate affect

    “aaaabbcccdd”

    it achieve afford { “a” : 1, “b” : 1, “c” :1, “d” : 1}