, HELLO WORLD !!! 123';
var letters = str.toLowerCase().split('');
var obj_count = {};
letters.forEach( (item) => {
obj_count[item] ? obj_count[item]++ : obj_count[item] = 1;
});
console.log('COUNTS', str, obj_count);
why is it better ? (honest question)
I agree, as I've written this before obj_count[item] ? obj_count[item]++ : obj_count[item] = 1; but obj_count[item] = obj_item[item] + 1 : 1;
Обсуждают сегодня