Generating all possible true/false combinations
<p>I want to create an array of all possible combinations of three variables that can either be true or false (i.e. 8 possible combinations).</p>

<p>I am trying to create the cube in the top left corner at this image</p>

<p><a href="https://i.stack.imgur.com/4iiuI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4iiuI.jpg" alt="enter image description here"></a></p>

<p>So the output should be something like</p>

<pre><code>points = [
  // first square
  {
    id: '000',
    truths: [false, false, false]
    position: [0, 0]
  },
  {
    id: '100',
    truths: [true, false, false]
    position: [5, 0]
  },
  {
    id: '010',
    truths: [false, true, false]
    position: [0, 5]
  },
  {
    id: '110',
    truths: [true, true, false]
    position: [5, 5]
  },
  // second square
  {
    id: '001',
    truths: [false, false, true]
    position: [2.5, 2.5]
  },
  {
    id: '101',
    truths: [true, false, true]
    position: [7.5, 2.5]
  },
  {
    id: '011',
    truths: [false, true, true]
    position: [2.5, 7.5]
  },
  {
    id: '111',
    truths: [true, true, true]
    position: [7.5, 7.5]
  },
];

lines = [
  { from: '000', to: '100' },
  { from: '000', to: '010' },
  { from: '000', to: '001' },

  { from: '100', to: '101' },
  { from: '100', to: '110' },

  { from: '001', to: '101' },
  { from: '001', to: '011' },

  { from: '101', to: '001' },
  { from: '101', to: '111' },

  ...
]
</code></pre>

<p>I don't know how to go through all possible truth values and create these points.</p>

<p>One approach could be to use a for loop</p>

<pre><code>for (var i=0; i&lt;Math.pow(2, 3); i++) {
  ...
}
</code></pre>

<p>but it doesn't help me assigning the possible truth values.</p>