I am completely perplexed here. From javascript I am using a .$get(php) script to bring in an array of "true" or "false" strings from a database (I know I should be easier to use bits rather than strings in the DB, but I can't, not my DB) called settingsArray. A console.log(settingsArray) returns the following:
["true", "false", "false", "false", "true"]
Then I have a couple If statements to see if any of them are "true", like this:
if(settingsArray[0] == "true" || settingsArray[1] == "true"){
if(settingsArray[2] == "true" || settingsArray[3] == "true" || settingsArray[4] == "true"){
do(function)
}else{
error(1);
}
}else{
error(2);
}
The code is then performing error(1), which it shouldn't.
I then tried this:
console.log(settingsArray[0] == "true");
console.log(settingsArray[1] == "true");
console.log(settingsArray[2] == "true");
console.log(settingsArray[3] == "true");
console.log(settingsArray[4] == "true");
console.log(settingsArray[0] == "true" || settingsArray[1] == "true" || settingsArray[2] == "true" || settingsArray[3] == "true" || settingsArray[4] == "true");
and am receiving:
False
False
False
False
False
True
What is happening here? How are the first and last not returning as True and if they are all False, how is the last statement True? I am soooooo confused.
Aucun commentaire:
Enregistrer un commentaire