# \[JS\] If Statement with "or" (||) - can you see a problem?

**URL:** <https://forum.kirupa.com/t/js-if-statement-with-or-can-you-see-a-problem/180631>\
**Category:** web dev\
**Created:** [March 2, 2006, 2:11am UTC](https://forum.kirupa.com/t/js-if-statement-with-or-can-you-see-a-problem/180631 "2006-03-02T02:11:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hgfl](https://avatars.discourse-cdn.com/v4/letter/h/8e7dd6/32.png) [@hgfl](https://forum.kirupa.com/u/hgfl)\
**Post date:** [March 2, 2006, 2:11am UTC](https://forum.kirupa.com/t/js-if-statement-with-or-can-you-see-a-problem/180631/1 "2006-03-02T02:11:17Z")

</div>

I have an if statement, as seen below.

```auto

if (l*.href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')
      && !l*.getAttribute('target')
      && !l*.parentNode.id.match(/^copy/)
      && l*.href.indexOf(your_domain) == -1) {
      //etc, etc
}

```

This works ok. But as soon as I change the last “and” (&&) to an “or” (||), there is a problem.

```auto

if (l*.href.split('/')[2].replace(/www\./, '') != document.domain.replace(/www\./, '')
      && !l*.getAttribute('target')
      && !l*.parentNode.id.match(/^copy/)
      || l*.href.indexOf(your_domain) == -1) {
      //etc, etc
}

```

This if statement is encased in a for loop, and with the “or” there, the loop just keeps on going, as if there is something not closed properly.  
Can anyone see a problem with the second piece of code above and why it doesn’t work when the first one does? Is there something else I can add in to get this working as it should?  
Thanks in advance
