this var obj_count = { a: 8, b: 1, c: 1, d: 2, h: 1, e: 1, l: 3, o: 2, w: 1, r: 1 } to output like this:
a: 8
b: 1
c: 1
d: 2
and so on??
i tried using a for loop i guess i am not getting it right:
for (var i = 0; i<obj_count.length; i++){
console.log(obj_count[i]);
}
Iterate over Object.prototype.keys it will help you to get it in desired format
Object.keys(obj_count).forEach(function (key) { console.log(key + ': ' + obj_count[key]); });
Обсуждают сегодня