Please, could somebody help me with a code review? Many thanks in advance


var categories = [];
var products = [];
var catalog = products;

var
Product = function (productID, category, name, price) {
this.productID = productID;
this.category = category;
this.name = name;
this.price = price;
},
Category = function (categoryID, name) {
this.categoryID = categoryID;
this.name = name;
};

var
CartItem = function(itemID, product, quantity) {
this.itemID = itemID;
this.product = product;
this.quantity = quantity;
},
ShoppingCart = function(cartID, items) {
this.cartID = cartID;
this.items = items;
};

var items = []; //collection of CartItem
var shoppingCart = new ShoppingCart(1 ,items );

//addCategoryToCatalog
function addCategoryToCatalog (categoryID, name) {
for (var i = 0; i < categories.length; i++) {
if (categories[i].categoryID === categoryID) {
return categories[i];
}
}
var categoryItem = new Category(categoryID, name);
categories.push(categoryItem);
}
addCategoryToCatalog(1, 'shoes');
addCategoryToCatalog(3, 'shirts');


//addProductToCatalog
function addProductToCatalog(productID, category, name, price) {
for (var i = 0; i < products.length; i++) {
if(products[i].productID === productID) {
return products[i];
}
}
var productItem = new Product(productID, category, name, price);
products.push(productItem);
}
addProductToCatalog(1, categories[0], 'boots', 400);
addProductToCatalog(2, categories[1], 'Flannel Shirt', 47.90);
addProductToCatalog(3, categories[0], 'Converse', 50.90);

//addItemToCart
function addItemToCart(itemID, product, quantity) {
for (var i = 0; i < items.length; i++) {
if(items[i].itemID === itemID) {
items[i].quantity += quantity;
return;
saveCart();
}
}

var item = new CartItem(itemID, product, quantity);
items.push(item);
}

addItemToCart(1, products[0], 4);
addItemToCart(2, products[1], 2);
addItemToCart(4, products[0], 20);

//removeItemfromCart(name) -> removes one item
function removeItemFromCart(itemID, product, quantity) {
for (var i = 0; i < items.length; i++) {
if(items[i].itemID === itemID) {
items[i].quantity--;
if( items[i].quantity === 0) {
items.splice(i, 1);
}
return;
}
}
saveCart();
}

removeItemFromCart(1);
removeItemFromCart(2);
removeItemFromCart(4);


function removeItemFromCartAll(itemID) {
for (var i in items ) {
if(items[i].itemID === itemID) {
items.splice(i, 1);
return;
}
}
saveCart();
}
removeItemFromCartAll(1);


//clearCart()
function clearCart() {
items = [];
saveCart();
}
//clearCart();


//countCart() -> return total count
function countCart() {
var totalCount = 0;
for(var i in items) {
totalCount += items[i].quantity;
}
return totalCount;
}
countCart();


//totalCart() ->return total cost
function totalCart() {
var totalCost = 0;
for(var i in items) {
totalCost += items[i].product.price;
}
return totalCost;
}
totalCart();


//listCart() -> returns an array of Item
// function listCart() {
// var cartCopy = [];
// for(var i in items) {
// var item = items[i];
// var itemCopy = {};
// for(var p in item) {
// itemCopy[p] = item[p];
// }
// cartCopy.push(itemCopy);
// }
// return cartCopy;
// }
//console.log(listCart());

//saveCart()
function saveCart() {
localStorage.setItem('items', JSON.stringify(items));
}
//loadCart()
function loadCart() {
var itemsCart = JSON.parse(localStorage.getItem('items'));
return itemsCart;
}
loadCart();



/* ============================================*/

function renderCart() {
var itemCopies = [];
for(var i in items) {

var $copy = $('.cart-selection').clone();

$('ul', $copy).html('<li>' + items[i].itemID + ''+ items[i].product.category.categoryID + ''+ ''+ ''+ items[i].product.category.name + ''+ items[i].product.name +''+ ''+ items[i].product.price + ''+ items[i].product.productID +''+ items[i].quantity + '</li>');

itemCopies.push($copy);
$copy.appendTo($('.product-list'));
}
return itemCopies;
}
renderCart();