From 59fbe685638757676cdfffea0b592275c8ea9a7b Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:40:07 -0500 Subject: [PATCH 1/9] section 1 --- index.html | 9 +++++++++ js/app.js | 23 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 index.html create mode 100644 js/app.js diff --git a/index.html b/index.html new file mode 100644 index 0000000..f707010 --- /dev/null +++ b/index.html @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/js/app.js b/js/app.js new file mode 100644 index 0000000..8946cd8 --- /dev/null +++ b/js/app.js @@ -0,0 +1,23 @@ +//1. +const arrObj = { + arr: [1,2,3], + isObj: true +} +console.log(arrObj.arr[1]); + +//2. +const objObj = { + obj: { + isObj: true, + properties: 2 + }, + isObj: true +} +console.log(objObj.obj.isObj); + +//4. +const objArr = [4,{ + isObj: true, + properties: 2 +}] +console.log(objArr[1].isObj); \ No newline at end of file From 9a17380b37d854b34af3341b931d53b7273e6d84 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:44:07 -0500 Subject: [PATCH 2/9] Commit 2 - Combine objects, arrays, and functions more than one level deep --- js/app.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index 8946cd8..3463739 100644 --- a/js/app.js +++ b/js/app.js @@ -1,3 +1,5 @@ +//Section 1 + //1. const arrObj = { arr: [1,2,3], @@ -20,4 +22,43 @@ const objArr = [4,{ isObj: true, properties: 2 }] -console.log(objArr[1].isObj); \ No newline at end of file +console.log(objArr[1].isObj); + +//Section 2 + +//1. +const objFunc = () => { + return { + isObj: true, + properties: 2 + }; +} +console.log(objFunc().isObj); + +//2. +const arrFunc = () => { + return [1,2,3]; +} +console.log(arrFunc()[0]); + +//3. +const arrObjFunc = () => { + return { + isObj: true, + arr: [1,2,3] + } +} +console.log(arrObjFunc().arr[0]); + + + + + + + + + + + + + From c08334b4c39351d72880f7a9c18c7f25353ea9b9 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:47:30 -0500 Subject: [PATCH 3/9] Commit 3 - Create a callback --- js/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/app.js b/js/app.js index 3463739..0507a5d 100644 --- a/js/app.js +++ b/js/app.js @@ -50,9 +50,17 @@ const arrObjFunc = () => { } console.log(arrObjFunc().arr[0]); +//Section 3 +const cbFunc1 = () => { + console.log("Hello"); +} +const cbFunc2 = (param) => { + return param; +} +cbFunc2(cbFunc1()); From fbbd0b1064280ec339eb73f638cb5ee90ad7bde0 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:49:16 -0500 Subject: [PATCH 4/9] Commit 4 - Indendation --- js/app.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/app.js b/js/app.js index 0507a5d..6702a11 100644 --- a/js/app.js +++ b/js/app.js @@ -62,6 +62,18 @@ const cbFunc2 = (param) => { cbFunc2(cbFunc1()); +//Section 4 +if(true){ + const a = 2 + 2; + console.log(a); +} + +if(true){ + if(false){ + console.log('hi'); + } +} + From ef2ae67406c680c80bbad512ef3c5ab19636c324 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:50:03 -0500 Subject: [PATCH 5/9] Commit 5 - Semantic naming of variables --- js/app.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/app.js b/js/app.js index 6702a11..9e3b9f5 100644 --- a/js/app.js +++ b/js/app.js @@ -74,6 +74,8 @@ if(true){ } } +//Section 5 +const numList = [2,4,6,8,10]; From 92526c362ad996a1fab35aa96592abe8fd4a60e6 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:51:34 -0500 Subject: [PATCH 6/9] Commit 6 - Function definition placement --- js/app.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/app.js b/js/app.js index 9e3b9f5..e43f98c 100644 --- a/js/app.js +++ b/js/app.js @@ -77,6 +77,17 @@ if(true){ //Section 5 const numList = [2,4,6,8,10]; +//Section 6 +const bar = ()=>{ + console.log('bar here'); +} +bar(); + +const foo = ()=>{ + console.log('foo here'); +} +foo(); + From 55d6548284bae4ec635ab46dc2421333025b6aab Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:53:49 -0500 Subject: [PATCH 7/9] Commit 7 - Commenting code --- js/app.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/app.js b/js/app.js index e43f98c..3d94e37 100644 --- a/js/app.js +++ b/js/app.js @@ -88,7 +88,14 @@ const foo = ()=>{ } foo(); - +//Section 7 +//Defines function with two parameters +const addTwoNums = (firstNum, secondNum)=>{ + //declares new variable, assigns variable value of sum of function's arguments + const finalValue = firstNum + secondNum; + //returns new variable + return finalValue; +} From 315c5af56185ffbd8bc9814bcbb559f7caf02940 Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:55:34 -0500 Subject: [PATCH 8/9] Commit 8 - Error reading --- js/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/app.js b/js/app.js index 3d94e37..a9f149d 100644 --- a/js/app.js +++ b/js/app.js @@ -97,6 +97,14 @@ const addTwoNums = (firstNum, secondNum)=>{ return finalValue; } +//Section 8 +foo(); + +const foo ()=>{ + console.log('hi'); +} +//The error message means that the function declaration is missing an equals sign + From ada78dd6a69dc14736a51a6264c94ff8f82d210d Mon Sep 17 00:00:00 2001 From: LehmanBrother Date: Fri, 21 Sep 2018 09:57:48 -0500 Subject: [PATCH 9/9] Commit 9 - Coerce data types --- js/app.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/js/app.js b/js/app.js index a9f149d..c993b8b 100644 --- a/js/app.js +++ b/js/app.js @@ -105,7 +105,15 @@ const foo ()=>{ } //The error message means that the function declaration is missing an equals sign +//Section 9 +const b = 5; +if(b === 5){ //will be false + console.log('this line should execute'); +} + +const a = '5'; +console.log(5 + Number(a));