JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 21st, 2013, 06:11 PM
epanagio's Avatar
epanagio epanagio is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Posts: 660 epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level)epanagio User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 5 h 32 m 17 sec
Reputation Power: 94
Conditional operator help

I am having a tough time understanding this "simple" conditional:
Quote:
if ((row != 3) && (i != 9)) {
alert('row is not 3 and i is not 9 ');
} else
alert('row: ' + row + ', i: ' + i);

When variable row equals to 3 and no matter what value variable i is then the if statement is not true.
The way I understand this I should get alert('row is not 3 and i is not 9 ') ONLY id row is 3 and variable i is nine.

HELP!
__________________
Evan

Reply With Quote
  #2  
Old January 21st, 2013, 06:32 PM
requinix's Avatar
requinix requinix is offline
Still alive
Click here for more information.
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,679 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 4 Days 1 h 46 m 33 sec
Reputation Power: 8969
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
No*: for the first branch to execute both "row is not 3" and "i is not 9" have to be true. The other branch will execute in the opposite case, namely if "row is not 3" is false or if "i is not 9" is false.
Once you've gotten a handle on that you can start simplifying the logic. Like getting rid of all those "is not"s in favor of just "is"s.

If "row is 3" then "row is not 3" is false and the second branch will execute.


* Everything else you said was right so I think that you typoed the "the way I understand this" statement.

Last edited by requinix : January 21st, 2013 at 06:35 PM.

Reply With Quote
  #3  
Old January 22nd, 2013, 09:49 AM
ZWEI01 ZWEI01 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2013
Posts: 10 ZWEI01 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 54 m 13 sec
Reputation Power: 0
'!=' means NOT equal to.


Code:
x = 10;                               
x != 10; //returns false             x == 10; //returns true

x = 9;
x != 10; //returns true


MDN has really great JS resources.
https://developer.mozilla.org/en-US...gical_Operators

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Conditional operator help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap