Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need to practice more. need to read more about JavaScript. #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script src="products.js"></script>
<script src="script.js"></script>
33 changes: 33 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//console.log("hello")
var total = 0;
for (i=0; i<products.items.length; i++) {
if (products.items[i].kind === 'shopping#product') {
total = total++;
}
}
console.log("Number of products " + products.items.length);

for (i=0; i<products.items.length; i++) {
if (products.items[i].product.inventories[0].availability === 'backorder') {
var print = products.items[i].product.title;
console.log(print);
}
}

// products - items[i] - product - images
console.log("3. Print the title of all items with more than one image link.");
for (i=0; i<products.items.length; i++) {
if (products.items[i].product.images.length > 1) {
var print = products.items[i].product.title;
console.log(print);
}
}

// products - items[i] - product - brand
console.log("4. Print all 'Canon' products in the items (careful with case sensitivity).");
for (i=0; i<products.items.length; i++) {
if (products.items[i].product.brand === "Canon") {
var print = products.items[i].product.title;
console.log(print);
}
}