0

Using the following code I want to push filtered[i] output into a single array instead of multiple arrays.

Any idea how do I do it?

var checkObject;
var filtered = s.Data.results.filter(function(el) {
  return el.result.indexOf(option) > -1
});
for (var i = 0; i < filtered.length; i++) {
  checkObject = filtered[i].path === 3;
  if (checkObject) {
    var object = [],
      hash = Object.create(null),
      notIn = [];
    object.push(filtered[i]);
    console.log(object);
    //
    object.forEach(function(a) {
      a.result.forEach(function(b) {
        hash[b] = true;
      });
    });

    notIn = s.Data.choices.filter(function(a) {
      return !hash[a.choice];
    });
    console.log(notIn);
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
dda
  • 6,030
  • 2
  • 25
  • 34
Markus Hayner
  • 2,869
  • 2
  • 28
  • 60

0 Answers0