title: Replace a part of a string with units of a number
body: <p>I want to implement a function in Google Spreadsheet using JavaScript. I have: </p>
  
  <pre><code>var s1 = "000000000000";  // (12 zeros)
  var n1 = 1;
  </code></pre>
  
  <p>I have a third number between 1 and 12. If my number is 6 the result would need to be: 111111000000. If my number is 8 the result would need to be 111111110000.</p>
  
  <p>So far I got stuck here: </p>
  
  <pre><code>function REP(b1) {
  
    var s1 = "000000000000" ;
    var n1 = 1;
  
  
    if (b1 &gt;=1 &amp;&amp; b1 &lt;= 12) {
  
      return s1.split("0").join(n1) ;
  
    }
    else{
      return "no value" ;
    }
  }
  </code></pre>