title: Functions in React: my function isn't working, because of 'read-only' error. Why?
body: <p>I'm trying to write a function into a React component, but I am stuck with this error:</p>
  <blockquote>
  <p>Uncaught Error: Module build failed: SyntaxError: &quot;productMap&quot; is read-only</p>
  </blockquote>
  <p>Why is this happening? And how can I fix this, so I can use <code>productMap</code>?</p>
  <p>Here is my function:</p>
  <pre><code>printReceipt() {
      var products = this.props.updateBasket.products;
  
      //create a map of products
  
      const productMap = {};
      for(let product of products) {
          if(!productMap[product.id]) {
              productMap[product.id] = 1;
          } else {
              productMap = productMap + 1; 
          }
      }
      console.log(productMap);
  }
  </code></pre>