Str to obj and number of occurrences

At the very least I know how I can throw this thing out the window :stuck_out_tongue:

Bear with me, I like to joke around when I’m frustrated. I would have to guess obj[i]++, but I’m not sure. I know I have to get rid of count, but confused on the data type that the other variable needs to be.

function letterCount(str) {
    let obj = {};

    for (let i of str) {
        if(obj.hasOwnProperty([i])) {
            obj[i]++;
        } else {
          obj[0] + i; 
        }
    }
    
    
    return obj;
};

Not right obviously, but trying. Very confused on if I need another variable to complete.

I wonder some times if I spend too much time on a problem.

EDIT: closer?

function letterCount(str) {
    let obj = {};

    for (let i of str) {
        if(obj.hasOwnProperty([i])) {
            obj[0] + i;
        } else {
          obj; 
        }
    }
    
    
    return obj;
};

I don’t understand how I’m supposed to remember every method for every data type.

EDIT: I might just come back to this later tonight. It’s frustrating I’m not where I want to be.

Could you just make it obj[i] += 1?

I’m sorry I must frustrate you to no end. I promise if I understand this within 2 years or so I will give back to the community.

EDIT: Will also have you know I physically facepalmed when I saw your solutions.

Let’s not get ahead of ourselves, I might be one of the few to hit that 2 year mark.