title: javascript for loop and match strings
body: <p>I have a problem with loops and comparisons with JSONObj. My code works except if the item does not exist in JSONObj.</p>
  
  <p>I want to compare 2 string <strong>JSONObj</strong> with <strong>res</strong> does not exist give me a message in myTextarea2 like the input <strong>BBB</strong> does not exist </p>
  
  <p>I tried boolen  <code>var isNomatch = ((JSONObj[i] == res[b]))</code></p>
  
  <p><code>if (isNomatch == false)</code> I think this ide is wrong</p>
  
  <p>or </p>
  
  <p><code>if((JSONObj[i] !== res[b])){</code></p>
  
  <p>and my for loop is odd</p>
  
  <p><strong>Html head</strong></p>
  
  <pre><code>&lt;input type="text" id="myText" value="26B,26N,245"&gt;
  &lt;button onclick="myFunction()"&gt;ok&lt;/button&gt;
  &lt;br&gt;
  &lt;textarea  id="myTextarea"&gt;Item&lt;/textarea &gt; 
  &lt;br&gt; 
  &lt;textarea  id="myTextarea2"&gt;&lt;/textarea &gt;  
  </code></pre>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>var JSONObj = [
      {"nummer":"26B", "item":"26B) Sonic Screwdriver\n\n"},
      {"nummer":"26N", "item":"26N) Pizza\n\n"},
      {"nummer":"245", "item":"245) I need Coffe\n\n"}
  
  ]
  
    function myFunction(){
        var str = document.getElementById("myText").value;
        var res = str.split(",");
  
        for(var b = 0; b &lt; res.length; b++) {
  
            for(var i = 0; i &lt; JSONObj.length; i++) {
  
                //Here is the problem
                if((JSONObj[i] !== res[b])){
                var str2 = res[i]; 
                var text2 = [text2,str2].join("");
        document.getElementById("myTextarea2").value  =text2;
            }
  
            //this one's OK 
            if (JSONObj[i].nummer === res[b]){ 
  
                var str1 = JSONObj[i].item; 
                var text1 = [text1,str1].join("");
        document.getElementById("myTextarea").value  =text1;
        document.getElementById("myTextarea").cols = "100";
        document.getElementById("myTextarea").rows = "20";
         } 
        } 
       } 
      }
  </code></pre>