Counting hits by domain
You can modify the input until there's nothing left of it.  In this example, I've used a regex with .replace() to shorten the FQDN.  

If you don't like regex, you could instead split the domain name on ., then in the loop use dom.join(".") to compose the object key, followed by dom.shift() to shorten the array.  With the array technique, the loop conditional is dom.length (instead of just dom).

function getDomainHits(arr){
    let total={};
    arr.forEach( row =&gt; {
        let [hits, dom] = row.split(",");
        hits=parseInt(hits);
        while ( hits &amp;&amp; dom ) { 
            total[dom] = (total[dom] || 0) + hits;
            dom = dom.replace( /^[^.]*\.?/, '' )
        }
    });
    return total;
}