find element by object field vuejs

Solutions on MaxInterview for find element by object field vuejs by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
showing results for - "find element by object field vuejs"
Simone
23 Jan 2019
1var data = {specs:[{Name:"Power",Value:"1"},{
2    Name:"Weight",Value:"2"},{Name:"Height",Value:"3"}]}
3    
4var valObj = data.specs.filter(function(elem){
5    if(elem.Name == "Power") return elem.Value;
6});
7
8if(valObj.length > 0)
9    console.log(valObj[0].Value)