Have been messing with this for awhile and cannot for the life of me figure out why assetQualifier[ii][0] never passes any of the conditional tests except "else".
We can see the console log that the variable type is, indeed, a number. So it is a number variable being compared with a number variable, within the correct range of numbers, and yet it fails to evaluate as "true" for any of the possible numbers.
I ran a series of tests in the console log, as well, and all of those tests resolve to false, even after I force the variable into a Number - which is redundant, I realize, but just to show that I covered all possible bases, in case there was some error in logic.
var rollFood = Math.floor(Math.random()*10);
var rollShelter = Math.floor(Math.random()*10);
var rollTerritory = Math.floor(Math.random()*10);
var rollMaterials = Math.floor(Math.random()*10);
var rollTools = Math.floor(Math.random()*10);
var rollGoods = Math.floor(Math.random()*10);
var rollCurrency = Math.floor(Math.random()*10);
var rollWater = Math.floor(Math.random()*10);
var assetQualifier = [[rollFood,"test"],[rollShelter,""],[rollTerritory,""],[rollMaterials,""],[rollTools,""],[rollGoods,""],[rollCurrency,""],[rollWater,""]];
console.log("assetQualifier.length: "+assetQualifier.length);
console.log("assetQualifier[0][1]: "+assetQualifier[0][1]);
console.log(typeof assetQualifier[0][0]); //this is a number, yes?
console.log(typeof Number(assetQualifier[0][0])); //and that is DEFINITELY a number...
var ii=0; //counter
while(ii<assetQualifier.length){
console.log("assetQualifier[ii][0]>0: "+Number(assetQualifier[ii][0])>0);
console.log("assetQualifier[ii][0]==0: "+Number(assetQualifier[ii][0])==0);
console.log("assetQualifier[ii][0]===0: "+assetQualifier[ii][0]===0);
console.log("assetQualifier[ii][0]==0: "+Number(assetQualifier[ii][0])==5);
console.log("assetQualifier[ii][0]==0: "+Number(assetQualifier[ii][0])<5);
if(assetQualifier[ii][0]===0){assetQualifier[ii][1]="is totally destitute in terms of"}
if(assetQualifier[ii][0]===1){assetQualifier[ii][1]="is cripplingly deficient in"}
if(assetQualifier[ii][0]===2){assetQualifier[ii][1]="has dodgy access to"}
if(assetQualifier[ii][0]===3){assetQualifier[ii][1]="has some limited access to"}
if(assetQualifier[ii][0]===4){assetQualifier[ii][1]="has modest access to"}
if(assetQualifier[ii][0]===5){assetQualifier[ii][1]="is equal to his/her peers in terms of"}
if(assetQualifier[ii][0]===6){assetQualifier[ii][1]="is faring a little better than average in terms of"}
if(assetQualifier[ii][0]===7){assetQualifier[ii][1]="could fairly be regarded as privileged in terms of"}
if(assetQualifier[ii][0]===8){assetQualifier[ii][1]="possesses a varied expanse of"}
if(assetQualifier[ii][0]===9){assetQualifier[ii][1]="is up to his/her ears in"}
if(assetQualifier[ii][0]===10){assetQualifier[ii][1]="is laughably subsumed by sheer glittering excess when it comes to"}
else{assetQualifier[ii][1]="has resources as of yet unknown in terms of"};
console.log("assetQualifier[ii][1]: "+assetQualifier[ii][1]);
ii++;
}
The outcome of this is always the "else", no matter what.
I think this snippet of code is sufficient to show what I'm going for, but in case it's relevant, the outcome is going to be output as a string in a captured DIV.
Any words of wisdom would be greatly appreciated.