Question: I need to develop a function whereby a type property gets appended to an array if it doesn't exist.

So the key will be of type and it should have a value of "dog".

Can someone kindly point out how I can iterate over the array to check if the key "type" exists and also provide guidance on how to append {type:"dog"} to the inner array if it doesn't exist. I tried animalArray[0][1]={type:"dog"} but it doesnt seem to work.

A typical array of animals will look like this:

```
labelTheDogs(
 [
  {name: 'Obi'}, 
  {name: 'Felix', type: 'cat'}
 ]
)
// should return [
 {name: 'Obi', type: 'dog'}, 
 {name: 'Felix', type: 'cat'}
]

```

Answer: 
This is not a nested array

```js
function labelTheDogs(dogs) {
  dogs.forEach(dog => {
    if (!dog.type) {
      dog.type = 'dog'
    }
  })
return dogs
}

const dogs = labelTheDogs(
  [{
      name: 'Obi'
    },
    {
      name: 'Felix',
      type: 'cat'
    }
  ]
)

console.log(dogs)
```
you can use the map function to do that

```js
const newArray = yourArray.map((element) => {
  if(!element.type){
    element.type = "dog";
  }else {
    return element
  }
})
```