I'm trying to create a lille script to go trough my page and check if a class is present in any `<div>`. If the class is present then there will be no action.

It will look for `class="blue"` and if it find it it will do nothing. If it doesn't fint `class="blue"` it will change background color for `class="yellow"`. What it does it change the background color for `class="yellow"` not matter what. What is wrong?

```js
$("div").each(function() {
  if (jQuery(this).attr('class') != undefined && jQuery(this).hasClass('blue')) {} else {
    $('.yellow').css('background', 'green')
  }
});
```

```css
.blue {
  background: blue;
  width: 100px;
  height: 100px;
}

.red {
  background: red;
  width: 100px;
  height: 100px;
}

.yellow {
  background: yellow;
  width: 100px;
  height: 100px;
}
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="blue">
  Blue
</div>

<div class="red">
  Red
</div>

<div class="yellow">
  Yellow
</div>
```