Randomize and split object into 2 arrays
<p>I have an object with 8 items - i want to split those items up into 2 arrays (randomised).</p>

<p><strong>What i want to achieve</strong>:</p>

<p><strong>object</strong>: {1, 2, 3, 4, 5, 6} : harcoded</p>

<p>From object, it should automatically create 2 separate arrays and take object items and randomise them into the array. Making sure that it does not repeat.</p>

<p><strong>array 1</strong>: [3, 5, 6]</p>

<p><strong>array 2</strong>: [2, 1, 4]</p>

<p>Code so far:</p>

<pre><code>var element = {
  1: {
    "name": "One element",
    "other": 10
  },
  2: {
    "name": "Two element",
    "other": 20
  },
  3: {
    "name": "Three element",
    "other": 30
  },
  4: {
    "name": "Four element",
    "other": 40
  },
  5: {
    "name": "Five element",
    "other": 50
  },
  6: {
    "name": "Six element",
    "other": 60
  },
  7: {
    "name": "Seven element",
    "other": 70
  },
  8: {
    "name": "Eight element",
    "other": 80
  }
};

function pickRandomProperty(obj) {
  var result;
  var count = 0;
  for (var prop in obj)
    if (Math.random() &lt; 1 / ++count)
      result = prop;
  return result;
}



console.log(pickRandomProperty(element));
</code></pre>