From ce4607b20a3d4ee165032a3cc6e1805f4c205f01 Mon Sep 17 00:00:00 2001 From: Luke Nemy Date: Mon, 1 May 2017 17:58:15 -0700 Subject: [PATCH 1/3] Day 1 specs and exercises --- bike-shop/src/stage1-literals.js | 21 ++++++++++++++++++++- jsinfo/Create_calculator | 20 ++++++++++++++++++++ jsinfo/Hello_Object | 8 ++++++++ jsinfo/Ladder | 17 +++++++++++++++++ jsinfo/Multipy_numeric_properties | 26 ++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 jsinfo/Create_calculator create mode 100644 jsinfo/Hello_Object create mode 100644 jsinfo/Ladder create mode 100644 jsinfo/Multipy_numeric_properties diff --git a/bike-shop/src/stage1-literals.js b/bike-shop/src/stage1-literals.js index c749dd2..950d76b 100644 --- a/bike-shop/src/stage1-literals.js +++ b/bike-shop/src/stage1-literals.js @@ -1,5 +1,24 @@ const myBike = { - // your code here + name: "Roadster", + price: 199.99, + frame: new frame() { + height: 55, + color: 'blue', + stlye: 'cruiser' + } + brakes: new brakes() { + front: false, + back: true + } + tires: new tires() { + diameter: 22, + type: 'fat' + } + rings: new rings() { + front: 2, + back: 5 + } } + module.exports = myBike diff --git a/jsinfo/Create_calculator b/jsinfo/Create_calculator new file mode 100644 index 0000000..ae1ae47 --- /dev/null +++ b/jsinfo/Create_calculator @@ -0,0 +1,20 @@ +//Create Calculator + +let calculator = { + + read() { + this.num1 = +prompt('num1?'); + this.num2 = +prompt('num2?'); + }, + sum() { + return this.num1 + this.num2; + }, + + mul() { + return this.num1 * this.num2; + }, +}; + +calculator.read(); +alert( calculator.sum() ); +alert( calculator.mul() ); diff --git a/jsinfo/Hello_Object b/jsinfo/Hello_Object new file mode 100644 index 0000000..4e53226 --- /dev/null +++ b/jsinfo/Hello_Object @@ -0,0 +1,8 @@ +//Hello Object + +let user = {} +user.name: 'John'; +user.surname: 'Smith'; +user.name = 'Pete'; + +delete user.name diff --git a/jsinfo/Ladder b/jsinfo/Ladder new file mode 100644 index 0000000..a7be386 --- /dev/null +++ b/jsinfo/Ladder @@ -0,0 +1,17 @@ +//Ladder + +let ladder = { + step: 0, + up() { + this.step++; + return this; + }, + down() { + this.step--; + return this; + }, + showStep: function() { // shows the current step + alert( this.step ); + return this; + } +}; diff --git a/jsinfo/Multipy_numeric_properties b/jsinfo/Multipy_numeric_properties new file mode 100644 index 0000000..380196f --- /dev/null +++ b/jsinfo/Multipy_numeric_properties @@ -0,0 +1,26 @@ +//Multipy Numeric Properties by 2 + +// before the call +let menu = { + width: 200, + height: 300, + title: "My menu" +}; + +multiplyNumeric(menu); + + function multiplyNumeric() { + for ( let key in obj ) { + if (typeof obj[key] == 'number') { + obj[key] *= 2; + } + } + } + + +// after the call +menu = { + width: 400, + height: 600, + title: "My menu" +}; From c8cce5eabd1ad1fe24e85df04ffdf53247c29c23 Mon Sep 17 00:00:00 2001 From: Luke Nemy Date: Tue, 2 May 2017 14:47:59 -0700 Subject: [PATCH 2/3] Updated filetypes --- jsinfo/{Create_calculator => Create_calculator.js} | 0 jsinfo/{Hello_Object => Hello_Object.js} | 0 jsinfo/{Ladder => Ladder.js} | 0 .../{Multipy_numeric_properties => Multipy_numeric_properties.js} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename jsinfo/{Create_calculator => Create_calculator.js} (100%) rename jsinfo/{Hello_Object => Hello_Object.js} (100%) rename jsinfo/{Ladder => Ladder.js} (100%) rename jsinfo/{Multipy_numeric_properties => Multipy_numeric_properties.js} (100%) diff --git a/jsinfo/Create_calculator b/jsinfo/Create_calculator.js similarity index 100% rename from jsinfo/Create_calculator rename to jsinfo/Create_calculator.js diff --git a/jsinfo/Hello_Object b/jsinfo/Hello_Object.js similarity index 100% rename from jsinfo/Hello_Object rename to jsinfo/Hello_Object.js diff --git a/jsinfo/Ladder b/jsinfo/Ladder.js similarity index 100% rename from jsinfo/Ladder rename to jsinfo/Ladder.js diff --git a/jsinfo/Multipy_numeric_properties b/jsinfo/Multipy_numeric_properties.js similarity index 100% rename from jsinfo/Multipy_numeric_properties rename to jsinfo/Multipy_numeric_properties.js From ea618724af5fd4f3ec762198885354789afa5de8 Mon Sep 17 00:00:00 2001 From: Luke Nemy Date: Tue, 2 May 2017 18:32:04 -0700 Subject: [PATCH 3/3] Fixed a function --- bike-shop/src/stage1-literals.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/bike-shop/src/stage1-literals.js b/bike-shop/src/stage1-literals.js index 950d76b..5b31013 100644 --- a/bike-shop/src/stage1-literals.js +++ b/bike-shop/src/stage1-literals.js @@ -1,23 +1,22 @@ const myBike = { - name: "Roadster", + name: 'Roadster', price: 199.99, - frame: new frame() { + frame: { height: 55, color: 'blue', - stlye: 'cruiser' - } - brakes: new brakes() { + style: 'cruiser' + }, + brakes: { front: false, back: true - } - tires: new tires() { + }, + tires: { diameter: 22, type: 'fat' - } - rings: new rings() { - front: 2, - back: 5 - } + }, + + rings: [2, 5], + }