```js
var tableBody = document.getElementById("firstTableBody"),
  secondTable = document.getElementById("secondTable");

function insertRow() {
  var Row = tableBody.insertRow();
  for (var c = 0; c < 3; c += 1) {
    Row.insertCell(c);
  }
  var Fruits = ["Apples", "Oranges", "Strawberries"],
    random_Fruits = Fruits[Math.floor(Math.random() * Fruits.length)];
  Row.cells[0].innerHTML = random_Fruits;
  Row.cells[1].innerHTML = 100;
  var Sellbtn = document.createElement('button');
  Sellbtn.innerHTML = "Sell"
  Sellbtn.onclick = function Sell() {
    if (secondTable.rows.length < 1) {
      var Row = secondTable.insertRow();
      for (var f = 0; f < 2; f += 1) {
        Row.insertCell(f);
      }
      Row.cells[0].innerHTML = this.parentNode.parentNode.cells[0].innerHTML;
      Row.cells[1].innerHTML = this.parentNode.parentNode.cells[1].innerHTML;
    } else {
      for (var i = 0; i < secondTable.rows.length; i += 1) {
        if (secondTable.rows[i].cells[0].innerHTML === this.parentNode.parentNode.cells[0].innerHTML) {
          secondTable.rows[i].cells[1].innerHTML = +this.parentNode.parentNode.cells[1].innerHTML;
        } else {
          var Rowz = secondTable.insertRow();
          for (var k = 0; k < 4; k += 1) {
            Rowz.insertCell(k);
          }

          Rowz.cells[0].innerHTML = this.parentNode.parentNode.cells[0].innerHTML;
          Rowz.cells[1].innerHTML = this.parentNode.parentNode.cells[1].innerHTML;
        }
      }
    }

  }
  Row.cells[2].appendChild(Sellbtn);
};
```

```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<body>
  <table border="1">
    <thead>
      <th>Item</th>
      <th>Sold</th>
      <th>
        <button onclick="insertRow()">Insert</button>
      </th>
    </thead>
    <tbody id="firstTableBody">
    </tbody>
  </table>

  <table border="1">
    <thead>
      <th>Item</th>
      <th>Sold</th>
    </thead>
    <tbody id="secondTable">
    </tbody>
  </table>
</body>
```

I insert a row with randomly inserted fruit name and a dynamically added button called sell. When I click on sell it should check if the fruit name of that row exists in the second table or not if so then it should add the sold amount in the row that's in the second table that has the same name. If not then simply add a new row in the second table with the name and sold amount. jQuery is ok.