- Mar 26, 2005
- 4,094
- 123
- 106
Let me give you two statements:
1)As long as the answer is not x OR not y, do something.
2)As long as the answer is not x AND y, do something.
In the first scenario, that something STILL gets done even if the answer is x or y...
But I just said "do it ONLY if answer is x or y" !!!! What gives? This is driving me nuts!
In the second case as long as the answer is x or y, something will be done as intended. But it SHOULDN'T, because the statement says "do it ONLY if BOTH x AND y are the answer TOGETHER, AT THE SAME TIME"!
My code: (wrong)
while (natBornCitizen !== 'Y'
|| natBornCitizen !== 'y'
|| natBornCitizen !== 'Yes'
|| natBornCitizen !=='yes'
|| natBornCitizen !== 'N'
|| natBornCitizen !== 'n'
|| natBornCitizen !== 'No'
|| natBornCitizen != 'no');
{ alert }
someone else's code that "fixed" mine: (correct)
while (natBornCitizen !== 'Y'
&& natBornCitizen !== 'y'
&& natBornCitizen !== 'Yes'
&& natBornCitizen !=='yes'
&& natBornCitizen !== 'N'
&& natBornCitizen !== 'n'
&& natBornCitizen !== 'No'
&& natBornCitizen != 'no');
{ alert }
And yet, I still dont understand this....
EDIT: Hmm... I think I just understood this by writing this post...
As long as the answer is not x OR not y, do something. this is the same as saying as long as the answer is x and y do something... But than again, who negated the OR to AND? We only negated not x, not y!
1)As long as the answer is not x OR not y, do something.
2)As long as the answer is not x AND y, do something.
In the first scenario, that something STILL gets done even if the answer is x or y...
But I just said "do it ONLY if answer is x or y" !!!! What gives? This is driving me nuts!
In the second case as long as the answer is x or y, something will be done as intended. But it SHOULDN'T, because the statement says "do it ONLY if BOTH x AND y are the answer TOGETHER, AT THE SAME TIME"!
My code: (wrong)
while (natBornCitizen !== 'Y'
|| natBornCitizen !== 'y'
|| natBornCitizen !== 'Yes'
|| natBornCitizen !=='yes'
|| natBornCitizen !== 'N'
|| natBornCitizen !== 'n'
|| natBornCitizen !== 'No'
|| natBornCitizen != 'no');
{ alert }
someone else's code that "fixed" mine: (correct)
while (natBornCitizen !== 'Y'
&& natBornCitizen !== 'y'
&& natBornCitizen !== 'Yes'
&& natBornCitizen !=='yes'
&& natBornCitizen !== 'N'
&& natBornCitizen !== 'n'
&& natBornCitizen !== 'No'
&& natBornCitizen != 'no');
{ alert }
And yet, I still dont understand this....
EDIT: Hmm... I think I just understood this by writing this post...
As long as the answer is not x OR not y, do something. this is the same as saying as long as the answer is x and y do something... But than again, who negated the OR to AND? We only negated not x, not y!
Last edited:
