title: Remove selected object from variable
body: <p>I have a problem with shopping cart i am building. One part of the code is not working properly and i cant find the option in JS to help me solve this problem. Buying and removing button working but the problem comes when the user removes one dish and after that adds more. Removed dish is reprinted again because it is allready stored in variable &quot;printingDishTxt&quot;. Im trying to find solution that removes the dish from the variable &quot;.printingDishTxt&quot;</p>
  <p>Do you have any suggestion to achieve such functionality?</p>
  <p>Thank you in advance</p>
  <p>Code i am using:</p>
  <pre><code>//Every time user click .button-buy the chosen dish is printing in shopping cart
  
  document.querySelectorAll(&quot;.button-buy&quot;).forEach(button =&gt;{
    button.addEventListener(&quot;click&quot;, (e)=&gt;{
  
        printingDishTxt+=`
        &lt;div&gt;
        &lt;p&gt;&quot;printing name&quot;&lt;/p&gt;
  
        &lt;div&gt;
        &lt;p&gt;&quot;printing price&quot;&lt;/p&gt;
        &lt;a class=&quot;remove-button &quot;&gt;&lt;i class=&quot;fas fa-minus-circle&quot;&gt;&lt;/i&gt;&lt;/a&gt;
        &lt;/div&gt;
        &lt;/div&gt;
        `
        dishes.innerHTML=printingDishTxt;
  
  //Every time user click the .remove-button the chosen dish is removing
  
          document.querySelectorAll(&quot;.remove-button&quot;).forEach(remove=&gt;{
            remove.addEventListener(&quot;click&quot;, (e)=&gt;{
  
                e.currentTarget.parentElement.parentElement.remove();
  
            });
          });
  
      });
    });
  </code></pre>