title: How can I multiply an HTML character entity reference or &nbsp;?
body: <p>I would like to draw a rectangle with a function in JavaScript, and I need to multiply the HTML character entity reference <code>&amp;nbsp;</code> to draw the spaces between the sides.</p>
  
  <p>Can I save the <em>character entity reference</em> on a variable and then multiply it like in Python?</p>
  
  <pre><code>function drawRectangle(side, figure) {
      var spaces = "&amp;nbsp;";
      for (var i=0; i &lt; side; i++) {
          document.write(figure);
      }
      for (var i=0; i&lt; side-2; i++) {
          document.write(figure + spaces*side + figure);
      }
      document.write("&lt;br&gt;");
      for (var i=0; i &lt; side; i++) {
          document.write(figure);
      }
  }
  </code></pre>