week2 examples

This commit is contained in:
gauthiier
2016-11-11 12:55:14 +01:00
parent e592c370d8
commit 95e96e1230
6 changed files with 322 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
// bookstore.js
/*
var book1_title = "Ways of Curating";
var book1_price = 16.95;
var book1_author = "Hans Ulrich Orbist";
var book2_title = "Ardor";
var book2_price = 39.5;
var book2_author = "Roberto Calasso";
var book3_title = "Why Grow Up?";
var book3_price = 15.95;
var book3_author = "Susan Neiman";
*/
var book1 = {
'title': "Ways of Curating",
'price': 16.95,
'author': "Hans Ulrich Orbist"
};
var book2 = {
'title': "Ardor",
'price': 39.5,
'author': "Roberto Calasso"
};
var book3 = {
'title': "Why Grow Up?",
'price': 15.95,
'author': "Susan Neiman"
};
var array_of_books = [
{ 'title': "Ways of Curating",
'price': 16.95,
'author': "Hans Ulrich Orbist"
},
{ 'title': "Ardor",
'price': 39.5,
'author': "Roberto Calasso"
},
{
'title': "Why Grow Up?",
'price': 15.95,
'author': "Susan Neiman"
}
];
function print_the_book(a_book) {
console.log('--------------');
console.log('Title: ' + a_book.title);
console.log('Price: ' + a_book.price);
console.log('Author: ' + a_book.author);
}
for(var i = 0; i < array_of_books.length; i++) {
print_the_book(array_of_books[i]);
}
// console.log(book1);
// console.log(book2);
// console.log(book3);
//console.log(book3.author);
//console.log(book3_author);
+11
View File
@@ -0,0 +1,11 @@
{
"name": "bookstore",
"version": "1.0.0",
"description": "test code for gr01 bookstore",
"main": "bookstore.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "gauthier",
"license": "ISC"
}