title: Check if items in 2d array form a rectangle
body: <p>I am looking for a simple JavaScript formula that will calculate whether the X that the user types in a box forms either a rectangle or a square.</p>
  <p>I have attempted a loop to do this but I think I have made this way too complex.</p>
  <p>Basically I have stored the data like this (typescript)</p>
  <p><code>public proposedArray: Array&lt;Array&lt;boolean&gt;&gt; = []; </code></p>
  <p>I have sketched a diagram below in what would be valid/invalid options.  Can anyone please help me?</p>
  <p>Thanks!</p>
  <p><a href="https://i.stack.imgur.com/k1xg9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k1xg9.png" alt="enter image description here" /></a></p>