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

```
Once you load your `json` content into a variable, it will become an array of objects, not strings, so a simple `===` comparison will not work. You can compare it with the correct property, which in your case, is `state`:

```js
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"},
]

const count = state_city.filter(item => item.state === 'Texas').length;
console.log(count);
```

If you still want to do string comparison, you can do it by `stringify`ing your json result. It will find any string occurrence in each object:

```js
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"},
]

const count = state_city.filter(item => JSON.stringify(item).includes('Texas')).length;
console.log(count);
```