arrays - Javascript - returning objects based on multiple properties -


I need to create a function that takes an array of object s And objects return a certain set of criteria that match what I've done so far is quite simple: (pseudocode)

  // input: conditions: {prop1: "x", prop2 : "Z"} // Source: [{prop1: x}, prop2: "y"}, {prop1: "x", prop2: "z"}; // output: array of objects with the same properties ; Values ​​/ / ex: // getObjects ({prop1: "x", prop2: "z"}, [{prop1: "x", prop2: "y"}, {prop1: "x", prop2: "z "}]); // Returns: [{prop1:" x ", Prop2: "z"}] // .... var for results = []; (Various prop in orb) {var match = false; (for different condoms in the circumstances) {if (cond === Prop.  

Where < Code> Conditions is an object that represents one or more properties that should be near the matching object.

The problem is that it is returning duplicate objects in any way , Which obviously In can be. I know that this is a standard way of completing (maybe programming 101 way), but my Google-foo is failing me.

Note: I can not use the Array.prototype Filter because of the reference I am running through a set or rows in a table and only match certain criteria I want to return those people to the account.

Actually there is the idea that same input object

You were very close to the solution.
If you get many points, then you will add 'row' to each match.
Just add once per line, later on loop on the status and loop on Android.
This position of curly brace is: <(Var i = 0; i & lt; source.length; i ++) {var row = source [i]; Var match = true; Var samePropCount = 0; For / p>

  var results = []; {If (cond === prop) {samePropCount ++; If (conditions [cond]! = Row [prop]) {match = false;}}}} if (! SamePropCount) match = wrong; If (match) {results.push (line); }} Return Results;  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -