samedi 25 août 2018

Conditions proof confusing

Given is res[]:

for(let k; k < res.length; k++)
    if($("#getData").val().length == 20){

      //if ((res[k]) != $("#getData").val()) helpText = "No match!";
      // -- Tried this too and a several other options - foreach, else, if else e. g.
      if(!((res[k]) == $("#getData").val()))
        resText = "No match!";
      if((res[k]) == $("#getData").val())
        resText = "Success!";

    $("#result").html(resText);
    }
}

If the !((res[k]) == $("#getData").val()) - "false" condition is defined, it always only makes the first res[0] item within the array valid. This item is possible to proof correctly - The array don´t iterate.

If the - "false" condition is not defined, all works fine if only the "true" condition is defined. But in this way there is no resText == "No match!";

What is wrong...?

Aucun commentaire:

Enregistrer un commentaire