title: how to replace string with another string in javascript
body: <p>I am trying to replace string with another string.</p>
  
  <pre><code>var string = "equity,40\n\
              equity-cap,15\n\
              cash,20\n";
  
  var output = string.replace(name, `${name},${value}`);
  
  //output 
  output = "equity,40\n\
              equity-cap,15\n\
              cash,80,20\n"
  
  var string = "equity,40\n\
              equity-cap,15\n\
              cash,20\n";
  
  var text = cash
  var value = 80
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var string = "equity,40\n\
                  equity-cap,15\n\
                  cash,20\n";
  var name = "cash";
  var value = 80;
  var output = string.replace(name, `${name},${value}`);
  
  //output 
  output = "equity,40\n\
                  equity-cap,15\n\
                  cash,80\n"
  
  console.log(output, "required output")</code></pre>
  </div>
  </div>
  </p>
  
  <pre><code>var output = "equity,40\n\
              equity-cap,15\n\
              cash,80\n";
  </code></pre>