0

i am trying to extract specific data from an array object using keys but all the data gets returned? why is that? i want to print to the console all the values corresponding to the key genestart only

for (var i=0; i<genedata.matches.length;i++){                                                                                                         
        var arr = genedata.matches[i];                                                                                                                    
        for (var key in arr){                                                                                                                             
            var attrName=key;                                                                                                                             
            var attrValue = arr[key];                                                                                                                     
            //console.log(attrValue);                                                                                                                     
            if (attrName='genestart'){                                                                                                                    
              console.log(attrValue);                                                                                                                     

            }                                                                                                                                             
        }                                                                                                                                                 
    }     
2
  • 3
    Please provide an example of what genedata looks like Commented Apr 23, 2018 at 1:03
  • 0: {…} ​​​ genename: "thrL" ​​​ genesrc: "NCBI_GP:AAN78501.1" ​​​ genestart: 190 ​​​ genestop: 255 ​​​ genestrand: 1 ​​​ productid: "AAN78501.1" ​​​ productname: "Thr operon leader peptide" Commented Apr 23, 2018 at 1:08

1 Answer 1

2

Your if statement is not a comparison but an assignment. Change = to ==

Sign up to request clarification or add additional context in comments.

1 Comment

No problem! Please approve the answer if that fixed it for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.