const charCount = {}
for (const char of modString1){
// if (charCount[char] === undefined) charCount[char] = 1
// else charCount[char]++
charCount[char] = charCount[char]++ || 1
}
So I have this for loop that I am iterating over each character of a string to generate the number of times it repeats. The commented out code works. My understanding charCount[char] = charCount[char]++ || 1 is the same but the code doesn't work it always returns 1 for every character. I have also tried the ternary operators as well with the same result. Anyone have answer to this quirk?