Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let users = {
- Alan: {
- age: 27,
- online: false
- },
- Jeff: {
- age: 32,
- online: true
- },
- Sarah: {
- age: 48,
- online: false
- },
- Ryan: {
- age: 19,
- online: true
- }
- };
- function countOnline(obj) {
- let count = 0;
- for (let user in obj) {
- if (obj[user].online) {
- count++;
- }
- }
- return count;
- }
- console.log(countOnline(users));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement