I am trying not to make the cart have duplicate items, instead I want the quantity to increase.
How can I compare the name in cart and the name that is about to be inputted from the product to the cart?
var total = document.getElementById('total');
var cart = document.getElementById("cart");
var totalPrice = 0;
function add(e) {
  var price = parseFloat(e.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.value);
  var quantity = parseFloat(e.previousSibling.previousSibling.value);
  var name = e.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.previousSibling.value;
  totalPrice += price * quantity;
  console.log("the name is " + name);
  cart.innerHTML += "<tr><td>" + name + "</td><td>" + quantity + "</td><td>" + price +
    "</td><td class='getT'>" + (price * quantity) +
    "</td><td class='btn btn-danger del'  id='del' onclick='del(this)'>Delete</td></tr>";
  total.innerHTML = "Total Price: " + totalPrice;
}<div id="total">TOTAL</div>
<div id="cart"></div>
<h3>Blackberry</h3>
<input type="text" value="Blackberry" class="name" id="name" style="display: none;">
Price: 50,000
<input type="number" id="price" value="50000"><br />
Quantity <input type="number" id="quantity" min="1" max="50" value="1" s>
<button class="AddtoCart" onclick="add(this)">ADD TO CART</button>
<h3>Iphone 5</h3>
<input type="text" value="iphone 5" class="name" id="name" style="display: none;">
Price: 100,000
<input type="number" id="price" value="100000"><br />
Quantity <input type="number" id="quantity" min="1" max="50" value="1">
<button class="AddtoCart" onclick="add(this)">ADD TO CART</button>
<h3>Iphone 6</h3>
<input type="text" value="iphone 6" class="name" id="name" style="display: none;">
Price: 150,000
<input type="number" id="price" value="150000"><br />
Quantity <input type="number" id="quantity" min="1" max="50" value="1">
<button class="AddtoCart" onclick="add(this)">ADD TO CART</button> 
     
     
     
    