javierdlm001
Technical User
According to page 26 in this PDF tutorial from Tutorials Point, it says the result would be "true", but is actually giving "false".
It goes like this:
Assume variable A holds 10 and variable B holds 20, then:
1. && (Logical AND)
If both the operands are non-zero, then the condition becomes true.
Ex: (A && B) is true.
Along the lines above, also in the same page, the one below is not giving what they said it would.
! (Logical NOT)
Reverses the logical state of its operand. If a condition is true, then the Logical NOT operator will make it false.
Ex: ! (A && B) is false.
document.write("!(a && b) => ");
result = (!(a && b));
document.write(result);
document.write(linebreak);
But it's giving me TRUE.
Also this one is not giving the expected result, in page 21:
<script>
<!--
var a = 10;
var b = 20;
var c = "Test";
var linebreak = "<br />";
a = a++;
document.write("a++ = ");
result = a++;
document.write(result);
document.write(linebreak);
b = b--;
document.write("b-- = ");
result = b--;
document.write(result);
document.write(linebreak);
//-->
</script>
It goes like this:
Assume variable A holds 10 and variable B holds 20, then:
1. && (Logical AND)
If both the operands are non-zero, then the condition becomes true.
Ex: (A && B) is true.
Along the lines above, also in the same page, the one below is not giving what they said it would.
! (Logical NOT)
Reverses the logical state of its operand. If a condition is true, then the Logical NOT operator will make it false.
Ex: ! (A && B) is false.
document.write("!(a && b) => ");
result = (!(a && b));
document.write(result);
document.write(linebreak);
But it's giving me TRUE.
Also this one is not giving the expected result, in page 21:
<script>
<!--
var a = 10;
var b = 20;
var c = "Test";
var linebreak = "<br />";
a = a++;
document.write("a++ = ");
result = a++;
document.write(result);
document.write(linebreak);
b = b--;
document.write("b-- = ");
result = b--;
document.write(result);
document.write(linebreak);
//-->
</script>