Iterate Through the Keys of an Object with a Statementfsafwegqeagfeag

Not sure what I’m doing wrong here. I would like to give more information on what exactly is confusing me, but the lesson itself doesn’t really give me much to work with here.

Your code so far

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) {
  // change code below this line
  for(let user in['true']);
  // change code above this line


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 OPR/55.0.2994.44.

Link to the challenge:

When using the for in syntax, the variable on the right side of the in should be an object.[‘true’] is not an object. In fact it is the value undefined, because the online property of users does not have a property named ‘true’.

Since the variable referenced on the right side of the in needs to be an object, which variable do you believe should go there?

FYI - Your for loop statement should not end with a semi-colon. Also it is recommended that you use { and } to warp any code you want to execute inside the for loop.

1 Like