TypeError: Cannot read property '0' of undefined when comparing the arrays?
<p>I have a array having JSON values </p>

<pre><code>category = [ {"categoryName":"abcd","productName":"chicken biriyani","price":100,"quantity":"medium"}, {"categoryName":"biriyani","productName":"mutton biriyani","price":130,"quantity":"medium"} ]
</code></pre>

<p>I have to check for the required parameters for the above category array.
so I created a required parameters array.
var reqarray = ['categoryName','productName','price','quantity'];</p>

<p>I created the sample code for checking the values of reqarray and each value of category.But it is not working</p>

<pre><code>var categoryList = [ {"categoryName":"abcd","productName":"chicken biriyani","price":100,"quantity":"medium"}, {"categoryName":"biriyani","productName":"mutton biriyani","price":130,"quantity":"medium"} ];
for(var i in categoryList){

        var reqarray =['categoryName','productName','price','quantity'];
        for(var j in arr){
            if(categoryList[i].reqarray[j]=='null' || categoryList[i].reqarray[j] == " "){
                console.log("data is null");
            }
            else if(categoryList[i].reqarray[j] == undefined){
                console.log("required parameters");
            }
            else{
                console.log("ok");
            }
        }
    }
}
</code></pre>

<p>This code shows an error :</p>

<pre><code>TypeError: Cannot read property '0' of undefined
</code></pre>