G
geoff
Hello
'just a little confused re how JavaScript treats 0 and 00, i.e. 1 zero
and 2 zeros.
Using
var nums = new Array();
nums[0] = 2;
nums[1] = 1;
nums[2] = 0;
nums[3] = 00;
var newcount = 0;
for (count=0;count<4;count++) {
alert(nums[count]);
if (nums[count] != 0 && nums[count] != 00) {
newcount++;
}
}
alert("final newcount = " + newcount);
Three points:
1. 00 is shown as 0 (via alert(nums[count])
2. whether I use && or ||
if (nums[count] != 0 && nums[count] != 00) {
or
if (nums[count] != 0 || nums[count] != 00) {
I get the same final newcount value of 2.
'would appreciate comments!
Cheers
Geoff
'just a little confused re how JavaScript treats 0 and 00, i.e. 1 zero
and 2 zeros.
Using
var nums = new Array();
nums[0] = 2;
nums[1] = 1;
nums[2] = 0;
nums[3] = 00;
var newcount = 0;
for (count=0;count<4;count++) {
alert(nums[count]);
if (nums[count] != 0 && nums[count] != 00) {
newcount++;
}
}
alert("final newcount = " + newcount);
Three points:
1. 00 is shown as 0 (via alert(nums[count])
2. whether I use && or ||
if (nums[count] != 0 && nums[count] != 00) {
or
if (nums[count] != 0 || nums[count] != 00) {
I get the same final newcount value of 2.
'would appreciate comments!
Cheers
Geoff