I am learning how to code and working on a Hack Reactor puzzle (see below). *I don't understand why the else part of my function block does not work. Can anyone point me in the right direction?*

> 
> Write a function called `getElementsThatEqual10AtProperty`.
> 
> 
> Given an object and a key, `getElementsThatEqual10AtProperty` returns
>  an array containing all the elements of the array located at the given
>  key that are equal to ten.
> 
> 
> Notes:
> 
> 
> * If the array is empty, it should return an empty array.
> * If the array contains no elements are equal to 10, it should return an empty array.
> * If the property at the given key is not an array, it should return an empty array.
> * If there is no property at the key, it should return an empty array.
> 
> 
> 

Example: 

```
var obj = { key: [1000, 10, 50, 10] };
var output = getElementsThatEqual10AtProperty(obj, 'key'); 
console.log(output); // > --> [10, 10]

```

**My Solution:**

```
var obj = {
  key: '[1000, 10, 50, 10]'
};

function getElementsThatEqual10AtProperty(obj, key) {
  if (typeof Array.isArray(obj[key])) {
    for (let key in obj) {
      tenArray = obj.key = obj[key].filter( element => element === 10);
    }
  } else {
    tenArray = obj.key = [];
  }
  return tenArray;
}

console.log(getElementsThatEqual10AtProperty(obj, 'key'))

```

Final Solution

```
var obj = {
  key: [1000, 10, 50, 10]
};

function getElementsThatEqual10AtProperty(obj, key) {
  if (Array.isArray(obj[key])) {
     tenArray = obj[key].filter( element => element === 10);
  } else {
    tenArray = [];
  }
  return tenArray;
}

console.log(getElementsThatEqual10AtProperty(obj, 'key'))

```
['https://Stackoverflow.com/questions/50389264', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8193814/']
Use only isArray to check for array, no need of `typeof` here.

```js
var obj = {
  key: '[1000, 10, 50, 10]'
};
console.log(Array.isArray(obj.key)) // false
console.log(typeof Array.isArray(obj.key)) // 'boolean'
console.log(Boolean(typeof Array.isArray(obj.key))) // true
```

Array at 'key' value should be declared without single-quotes, else it will be treated as string.

```js
var obj = {
  key: [1000, 10, 50, 10]
};
console.log(Array.isArray(obj.key)) // true
```

There is no need for a `for ..in` here as the key is already known. Also no need to modify obj.key I guess.

```
  if (Array.isArray(obj[key])) {
     tenArray = obj[key].filter( element => element === 10);
  }

```
Your problem is that you set `obj.key` instead of `obj[key]` in the `else` part of your function.