Question: Everyone!
I have an array of items, and I want to return a number of how many values match a specific State in the US.
For example, this is working code:
<https://jsfiddle.net/fkj3bq5g/>

JS:

```
const arr = ["Texas","Austin","TX","Texas","San Antonio","TX","California","Los Angeles","CA"];
const results = arr.filter(elem => elem === "Texas").length;
document.getElementById("demo").innerHTML = results;

```

html:

```
<span>Texas Cities:</span><span id="demo"></span>

```

I''m trying to match "Texas" and it should return "2",which it does.
However, I encounter a problem as soon as I'm trying to put an array from a JSON file, which has characters like `{, ``}` and `:` - I'm not getting any results. I'm not sure why since I'm pretty much a noob anyway.

Here's an example how the array in the `.json` file looks like:

```
var state_city = [
{"state":"Texas","city":"Houston","code":"TX"},
{"state":"Texas","city":"Dallas","code":"TX"},
{"state":"Texas","city":"Austin","code":"TX"},
{"state":"California","city":"Los Angeles","code":"CA"},
{"state":"California","city":"Sacramento","code":"CA"},
{"state":"California","city":"Anaheim","code":"CA"},
]

```

How do i make this work?

Answer: 
The problem is in this line:

```js
const results = arr.filter(elem => elem === "Texas").length

```

Now each `elem` evaluates to an object in `state_city`, so you want to modify your code a little:

```js
const results = arr.filter(elem => elem.state === "Texas").length

```
In your sample code you iterates a simple array of strings. So, you've defined that array as follows.

```
const arr = ["Texas","Austin","TX","Texas","San 
Antonio","TX","California","Los Angeles","CA"];

```

So, you can iterate all the elements in that array and filter out how many times your condition is true. As you did.

```
const results = arr.filter(elem => elem === "Texas").length;

```

But in your .json file, you have defined a different format of an array compared to previous one. It is an array of 
 objects.

```
var state_city = [
{"state":"Texas","city":"Houston","code":"TX"},
{"state":"Texas","city":"Dallas","code":"TX"},
{"state":"Texas","city":"Austin","code":"TX"},
{"state":"California","city":"Los Angeles","code":"CA"},
{"state":"California","city":"Sacramento","code":"CA"},
{"state":"California","city":"Anaheim","code":"CA"},
]

```

In here `var state_city` is the array and {} are objects 
 inside that array.

So, you can't directly access those attributes which you 
 declared in those objects by using the above mentioned 
 way.

So, you have to try this way.

```
const results = state_city.filter(elem => elem.state === 
"Texas").length;

```