I want to make a list of the richest user using JSON
So there's my code
var users = {'Johnny': {points: 20}, 'Kyle': {points: 30}};
I want it logged in console like
1. Kyle points: 30
2. Johnny points: 20
So how?
I want to make a list of the richest user using JSON
So there's my code
var users = {'Johnny': {points: 20}, 'Kyle': {points: 30}};
I want it logged in console like
1. Kyle points: 30
2. Johnny points: 20
So how?
Object.keys(users).forEach(function(name, index){
console.log((index + 1) + '. ' + name + ' points: ' + users[name].points);
});