diff --git a/index.html b/index.html new file mode 100644 index 0000000..390e834 --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/js/google_shopping_functions.js b/js/google_shopping_functions.js index bfbfdcf..9e25dec 100755 --- a/js/google_shopping_functions.js +++ b/js/google_shopping_functions.js @@ -4,14 +4,201 @@ * input: accepts full item data * output: returns the length of the items array */ -function getItemsCount(itemData) { - return itemData.items.length; +function getItemsCount(products) { + return products.items.length; } /* * Define and use your functions here */ +//1.) getItems(objectData) +//Create a function called getItems that simply returns the items array from the google product object. +function getItems(objectData) { + return objectData.items; +} + +//2.) getItemsByBrand(items, brand) +//Create a function called getItemsByBrand that takes an item array returns a new array of all items of a specified brand. +function getItemsByBrand(items, brand) { + var arrayBrand = []; + for (i=0; i price) { + arrayMinP.push(items[i]); + } + } + return arrayMinP; +} + +//Search by country +function getItemsByCountry(items, country) { + var arrayCtry = []; + for (i=0; i