Feedback on solution

Tell us what’s happening:

Hi! So, I solved this problem but I just wanted to get some feedback on whether on not this is an efficient solution when compared to the ones that are already given as answers.

How can I judge whether or not one solution is better than another? If so, then what are the parameters of deciding so?

All feedback is accepted!

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) {
// Only change code below this line
const check = ['Alan', 'Jeff', 'Sarah', 'Ryan'];

for(let i = 0; i < check.length; i++){
let user = check[i];
if(!users.hasOwnProperty(user)){ 
  return false;
  } else {
  continue;
  }
// Only change code above this line
}
return true;
}

console.log(isEveryoneHere(users));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0.

Challenge: Check if an Object has a Property

Link to the challenge:

at this level a solution that works should be your goal

then, once it works, some refactoring can be needed:
a solution should be readable, and that means using descriptive names for variables, adding comments if needed, respecting DRY (don’t repeat yourself) principles, removing unnecessary code (for example the else {continue} is not necessary) etc

1 Like

Appreciate the constructive feedback! Sometimes over-engineering the code makes it wet :stuck_out_tongue: