Checking to see if property exist

Checking to see if property exist


Tell us what’s happening:
so my if statement is suppose to return true if the property exist in object and false if it does not exist
my second if statement is not working please tell me whats going on.

Your code so far

let users = {
  Alan: {
    age: 27,
    online: true
  Jeff: {
    age: 32,
    online: true
  Sarah: {
    age: 48,
    online: true
  Ryan: {
    age: 19,
    online: true

function isEveryoneHere(obj) {
  // change code below this line
let counter = 0;
    for (let user in obj) {
        if(obj[user].online === true){
            counter ++;
            return true
            if (!obj[user].online) {
              return false
    return counter;
  // change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:


Why are you checking a user’s online property is true or not? Nothing in the challenge asks you to check for this. Also, I am not sure why you have a counter variable. The challenge expects you to return a true value if obj contains property names Alan, Jeff, Sarah, and Ryan or false if one or more of these names is not present as a property of obj.


You are looping through an object.

The first thing you are doing is checking to see if a first user in the object has status of online === true. If it’s yet, then you are returning true to get out of the loop and the function.

So I wouldn’t put return true right after your first check. I would only return true after your condition meets your requirements. I also wouldn’t put another if statement in the same block as your if statement after return true, because it will never be executed.


I misinterpreted between the if value of true or checking the value exist within the object.