I have **2 arrays**.

**The 1st array** has **4 category objects** and **each object** has **"name" and "ref"(reference)**:

```js
let categories = [
  {
    "name": "Books", 
    "ref": "categories/category1"
  },
  {
    "name": "Computers", 
    "ref": "categories/category2"
  },
  {
    "name": "Drink", 
    "ref": "categories/category3"
  },
  {
    "name": "Food", 
    "ref": "categories/category4"
  }
];

```

**The 2nd array** has **the references to categories**:

```js
let refs = ["categories/category2", "categories/category4"];

```

Now, I want to make **the new array of category names** by extracting **only category names** from **the 1st array "categories" variable** using **the references in the 2nd array "refs" variable**.

I created **the code to make the new array of category names** using **2 arrays** and **it works perfectly** making **the new array which has 2 category names "Computer" and "Food"**:

```js
let newArr = [];

for(let i = 0; i < refs.length; i++) {
  for(let j = 0; j < categories.length; j++) {
    if(refs[i] == categories[j].ref) {
      newArr.push(categories[j].name);
    }  
  }
}

console.log(newArr); // ["Computer", "Food"]

```

This is **the full runnable code**:

```js
let categories = [
  {
    "name": "Book", 
    "ref": "categories/category1"
  },
  {
    "name": "Computer", 
    "ref": "categories/category2"
  },
  {
    "name": "Shoes", 
    "ref": "categories/category3"
  },
  {
    "name": "Food", 
    "ref": "categories/category4"
  }
];

let refs = ["categories/category2", "categories/category4"];

let newArr = [];

for(let i = 0; i < refs.length; i++) {
  for(let j = 0; j < categories.length; j++) {
    if(refs[i] == categories[j].ref) {
      newArr.push(categories[j].name);
    }  
  }
}

console.log(newArr); // ["Computer", "Food"]
```

However, I want to **make this code simpler**. Are there any ways to **make this code simpler**?

```js
let newArr = [];

for(let i = 0; i < refs.length; i++) {
  for(let j = 0; j < categories.length; j++) {
    if(refs[i] == categories[j].ref) {
      newArr.push(categories[j].name);
    }  
  }
}

console.log(newArr); // ["Computer", "Food"]

```