# Solution doesn't work

**URL:** <https://forum.freecodecamp.org/t/solution-doesnt-work/425235>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 12, 2020, 2:17pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235 "2020-10-12T14:17:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan.brookman](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordan.brookman/32/182811_2.png) [@jordan.brookman](https://forum.freecodecamp.org/u/jordan.brookman)\
**Post date:** [October 12, 2020, 2:17pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/1 "2020-10-12T14:17:52Z")

</div>

In the JavaScript Data Structures curriculum, I am on the following lesson:

## Basic Data Structures: Iterate Through the Keys of an Object with a for…in Statement

My solution matches the one in the guide, and yet it is not being accepted. The code is as follows:

```auto
function countOnline(usersObj) {
  // Only change code below this line
  let result = 0;
  for (let user in userObj) {
    if (userObj[user].online === true) {
      result++; 
    }
  }
  return result;
  // Only change code above this line
}

```

The output console displays the following:

```auto
// running tests
The function countOnline should return 1 when the object { Alan: { online: false }, Jeff: { online: true }, Sarah: { online: false } } is passed to it
The function countOnline should return 2 when the object { Alan: { online: true }, Jeff: { online: false }, Sarah: { online: true } } is passed to it
The function countOnline should return 0 when the object { Alan: { online: false }, Jeff: { online: false }, Sarah: { online: false } } is passed to it
// tests completed

```

Does anyone know what the problem is? Thank you in advance.

Challenge link: [https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for---in-statement](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-data-structures/iterate-through-the-keys-of-an-object-with-a-for---in-statement)

Solution guide link: [freeCodeCamp Challenge Guide: Iterate Through the Keys of an Object with a for...in Statement](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-iterate-through-the-keys-of-an-object-with-a-for-in-statement/301162)

\*Edited to add links.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [October 12, 2020, 2:19pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/2 "2020-10-12T14:19:20Z")

</div>

Hi and welcome to the forum.

Please provide a link to the challenge and the guide post so we can help you troubleshoot.

---

<div class="post-metadata">

**Author:** ![jordan.brookman](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordan.brookman/32/182811_2.png) [@jordan.brookman](https://forum.freecodecamp.org/u/jordan.brookman)\
**Post date:** [October 12, 2020, 2:28pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/3 "2020-10-12T14:28:51Z")

</div>

Hi and thank you. I have edited the original post to add the links to the challenge and solution guide.

---

<div class="post-metadata">

**Author:** ![jeremy.a.gray](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremy.a.gray/32/181458_2.png) [@jeremy.a.gray](https://forum.freecodecamp.org/u/jeremy.a.gray)\
**Post date:** [October 12, 2020, 2:35pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/4 "2020-10-12T14:35:43Z")

</div>

Your function argument is named `usersObj` and you’re iterating over `userObj` in your `for...in` loop.

---

<div class="post-metadata">

**Author:** ![jordan.brookman](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jordan.brookman/32/182811_2.png) [@jordan.brookman](https://forum.freecodecamp.org/u/jordan.brookman)\
**Post date:** [October 12, 2020, 2:39pm UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/5 "2020-10-12T14:39:56Z")

</div>

Wow, I can’t believe I didn’t notice that typo, that’s embarrassing. 😩 Thank you for your help! 😃

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 10:39am UTC](https://forum.freecodecamp.org/t/solution-doesnt-work/425235/6 "2021-06-01T10:39:04Z")

</div>


