title: How to update list in javascript?
body: <p>I am implementing list using ul li. So I already have 4 list values and all values are null but one variable is getting some values so I want to replace it with the existing value.
  <strong>I am sharing my code.</strong></p>
  
  <p><strong>JavaScript</strong></p>
  
  <pre><code> var emptyLegend='&lt;ul&gt;
  &lt;li&gt;red(0)&lt;/li&gt;
  &lt;li&gt;yellow(0)&lt;/li&gt;
  &lt;li&gt;green(0)&lt;/li&gt;
  &lt;li&gt;purple(0)&lt;/li&gt;
  &lt;/ul&gt;'
  
  var legend='&lt;ul&gt;
  &lt;li&gt;red(3)&lt;/li&gt;
  &lt;/ul&gt;'
  </code></pre>
  
  <p>variable legend is dynamic. If var legend has red(4),yellow(5) then output should be:</p>
  
  <pre><code>'&lt;ul&gt;
      &lt;li&gt;red(4)&lt;/li&gt;
      &lt;li&gt;yellow(5)&lt;/li&gt;
      &lt;li&gt;green(0)&lt;/li&gt;
      &lt;li&gt;purple(0)&lt;/li&gt;
      &lt;/ul&gt;'
  </code></pre>
  
  <p>I want to replace red(0) with red(3);</p>