Complete the code to initialize an empty object to store character counts.
const charCount = [1];We use an empty object {} to store character counts as key-value pairs.
Complete the code to loop through each character in the string.
for (const [1] of input) { // process character }
We use char to represent each character in the string as we loop through it.
Fix the error in updating the character count in the object.
charCount[char] = (charCount[char] || [1]) + 1;
If the character is not yet in the object, we start counting from zero before adding one.
Fill both blanks to create a frequency map for characters longer than 2.
const freqMap = {
[1]: [2] for (const char of input) if char.length > 2
};char.length as key or value which is incorrect.input which is the whole string, not a key.The key is the character itself, and the value is its count from charCount.
Fill all three blanks to filter and map characters with count greater than 1.
const filtered = Object.fromEntries( Object.entries(charCount).filter(([[1], [2]]) => [3] > 1) );
We destructure entries as [char, value], then filter where value (count) is greater than 1.
