title: Replacing Text Inside of Curley Braces JavaScript
body: <p>I am trying to use JavaScript to dynamically replace content inside of curly braces. Here is an example of my code:</p>
  
  <pre><code>var myString = "This is {name}'s {adjective} {type} in JavaScript! Yes, a {type}!";
  var replaceArray = ['name', 'adjective', 'type'];
  var replaceWith = ['John', 'simple', 'string'];
  
  for(var i = 0; i &lt;= replaceArray.length - 1; i ++) {
    myString.replace(/\{replaceArray[i]\}/gi, replaceWith[i]);
  }
  
  alert(myString);
  </code></pre>
  
  <p>The above code, should, output "This is John's simple string in JavaScript! Yes, a string!".</p>
  
  <p>Here is what happens:</p>
  
  <ol>
  <li>we are given a string with values in braces that need replaced</li>
  <li>a loop uses "replaceArray" to find all of the values in curly braces that will need replaced</li>
  <li>these values, along with the curly braces, will be replaced with the corresponding values in the "replaceWith" array</li>
  </ol>
  
  <p>However, I am not having any luck, especially since <strong>one value may be replaced in multiple locations</strong>, and that I am dealing a dynamic value inside of the regular expression. </p>
  
  <p>Can anyone help me fix this, using a similar setup as above?</p>