-
-
Save SoxFace/6d4712ed66a8889b251e to your computer and use it in GitHub Desktop.
Revisions
-
robinsonlam revised this gist
Aug 9, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,7 @@ _Arrays_: **element:** The item you want to put into the array (collection). _Objects_: **key:** The "label" you wish to give to your item. This can also be a string e.g.( `"9", "chicken nugget"` ). **value:** The actualy item you want to put in your object. _Example:_ -
robinsonlam revised this gist
Aug 9, 2015 . 1 changed file with 7 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -105,12 +105,18 @@ We then call our function **drink()** without passing any arguments (you must in Then we have defined another function named **speak** that takes **1** argument: **amountOfBeers**. We then tell it to `return` a `string` of text depending on how many beers we've had. If we pass in anything between **1** and **4** will give us _"I'm fiiiiine."_, anything between **5** and **7**, he will lie and say _"I'm not drunk! I swear!"_ and anything equal or greater than **8** and this guy will need a taxi. If we specify **0** drinks, it will default to our final `else` and give us _"Where the drinks at?"_. We then call our function **speak**, passing it the number **8** ( `speak(8)` ). It will go through the function and give us back a `string` _"I can't feel my face."_. To use this `string` we can use it in `console.log()` and it will print out _"I can't feel my face."_ to our console! **Note:** `console.log()` is a function too! The argument you pass in is what you want to output! -
robinsonlam revised this gist
Aug 9, 2015 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -98,11 +98,17 @@ var speak = function(amountOfBeers) { console.log( speak(8) ); // instead we put in 8 ``` Okay so here we have a really crappy example that I will probably change later. First we have defined a function named **drink** that takes **0** arguments, then we tell it to increment **beersHad** by **1** every time the function is run. We don't specify anything to `return` because we don't need this function to give us back anything. We then call our function **drink()** without passing any arguments (you must include the parentheses `()` even with no arguments) and it will increment our beersHad by **1**. Then we have defined another function named **speak** that takes **1** argument: **amountOfBeers**. We then tell it to `return` a `string` of text depending on how many beers we've had. If we pass in anything between **1** and **4** will give us _"I'm fiiiiine."_, anything between **5** and **7**, he will lie and say _"I'm not drunk! I swear!"_ and anything equal or greater than **8** and this guy will need a taxi. If we specify **0** drinks, it will default to our final `else` and give us _"Where the drinks at?"_. We then call our function **speak**, passing it the number **8** ( `speak(8)` ). It will go through the function and give us back a `string` _"I can't feel my face."_. To use this `string` we can use it in `console.log()` and it will print out _"I can't feel my face."_ to our console! -
robinsonlam revised this gist
Aug 9, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,8 +70,8 @@ var functionName = function(argument, argument) { return stuffToReturn; } ``` **functionName:** The function's name. **argument:** These are variables you will use in your function, when you call your function you will pass/put in these variables. **return:** This is what the function will spit out after it's done, in a way the function will equal this. It will be clarified in the example. _Example:_ ``` -
robinsonlam revised this gist
Aug 9, 2015 . 1 changed file with 46 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -62,6 +62,52 @@ var zacharyFraser = { // 5. * `catchPhrases: ` which is an array of all his favourite catchphrases. **Note:** We have not used any semicolons when defining these elements, this is because they are seperated just like an array, with commas. (Refer back to the shoebox analogy located in the tips above.) # Functions ``` var functionName = function(argument, argument) { doStuff(); return stuffToReturn; } ``` **functionName:** The function's name. **argument:** These are variables you will use in your function, when you call your function you will pass/put in these variables. **return:** This is what the function will spit out after it's done, in a way the function will equal this. It will be clarified in the example. _Example:_ ``` var beersHad = 0; var drink = function() { beersHad = beersHad + 1; }; drink(); // beersHad is now 1 var speak = function(amountOfBeers) { if (amountOfBeers >= 8) { return "I can't feel my face."; } else if (amountOfBeers >= 5 && amountOfBeers < 8) { return "I'm not drunk! I swear!"; } else if (amountOfBeers >= 1 && amountOfBeers < 5) { return "I'm fiiiiine."; } else { return "Where the drinks at?"; } } console.log( speak(8) ); // instead we put in 8 ``` Okay so here we have a really crappy example that I will probably change later. First we have defined a function named **drink** that takes **0** arguments, then we tell it to increment **beersHad** by **1** every time the function is run. We don't specify anything to `return` because we don't need this function to give us back anything. (Except our dignity.) We then call our function **drink()** without passing any arguments (you must include the parentheses `()` even with no arguments) and it will increment our beersHad by **1**. Then we have defined another function named **speak** that takes **1** argument: **amountOfBeers**. We then tell it to `return` a `string` of text depending on how many beers we've had. If we pass in anything between **1** and **4** will give us _"I'm fiiiiine."_, anything between **5** and **7**, he will lie and say _"I'm not drunk! I swear!"_ and anything equal or greater than **8** and this guy will need a taxi. If we specify **0** drinks, it will default to our final `else` and give us _"Where the drinks at?"_. We then call our function **speak**, passing it the number **8** ( `speak(8)` ). It will go through the function and give us back a `string` _"I can't feel my face."_. To use this `string` we can use it in `console.log()` and it will print out _"I can't feel my face."_ to our console! **Note:** `console.log()` is a function too! The argument you pass in is what you want to output! # Control Flow Statements ### If Statement ``` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -147,7 +147,7 @@ while ( x < 10 ) { ``` We first define `x` as **0**. We then create our `while` loop, specifying that `x` needs to be less than **10** to run this loop ( `x < 10` ). As the loop runs, it will call `console.log("We are on loop: " + (x+1));`. We also need to add something that will eventually make our condition return `false`, so we increment `x` by **1** every time the loop runs, which will eventually make `x` greater than or equal to **10**, stopping our loop. This loop should output: -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 27 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -109,7 +109,7 @@ if (trafficLight === "green") { ### For loop ``` for ( initalize ; conditiontoloop ; lastexpression ) { doStuff(); } ``` _Example:_ @@ -124,6 +124,32 @@ which outputs: "**We are on loop: 1**" the first time because `x` is **0** and we have specified it to show `x + 1`. Then it will increment `x` as we have specified earlier ( `x++` ). This loop should output: _We are on loop: 1_ _We are on loop: 2_ ... _We are on loop: 9_ _We are on loop: 10_ ### While loop ``` while ( condition ) { doStuff(); } ``` _Example:_ ``` var x = 0; while ( x < 10 ) { console.log("We are on loop: " + (x+1)); x++; } ``` We first define `x` as **0**. We then create our `while` loop, specifying that `x` needs to be less than **10** to run this loop ( `x < 10` ). As the loop runs, it will call `console.log("We are on loop: " + (x+1));`. We also need to add something that will eventually make our condition return `false`, so we increment `x` by **1** every time the loop runs, which will eventually make `x` greater than or equal to **10**, stopping our loop. This loop should output: _We are on loop: 1_ _We are on loop: 2_ -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ Here are some notes I've made to help you guys with your syntax. Think of it like a "cheatsheet". Some tips to remember: * Keep an eye on semicolons, usually control flow blocks (`if` blocks, `for, while` loops etc.) do not need a semicolon. * Keep an eye on your opening and closing brackets ( `{ & }` ). * Be careful when using assignment operators ( `=` ) and equality operators ( `== and ===` ). Assignment is for setting, equality is for comparing. * Keep an eye on quotation marks. Match doubles with doubles ( `"` ), singles with singles ( `'` ). * **Also:** Watch when you're using apostrophes inside strings: ` var sentence = "You're weird"; `. Make sure you don't do this: ` var sentence = 'You're weird'; ` This will give you errors. -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,8 +40,10 @@ _Example:_ var age = 32; // 1. var firstName = "Zac"; // 2. var isWeird = true; // 3. var catchPhrases = ["Cya insertlastnamehere.", "Rob's the best."]; // 4. var zacharyFraser = { // 5. name: firstName, age: age, isWeird: true, -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,9 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik ``` var variableName = value; // Numbers, Booleans var variableName = "value"; // Strings var variableName = [element, element]; // Arrays var variableName = { // Objects key: value, key: value -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 9 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -89,11 +89,15 @@ if (condition) { _Example:_ ``` var trafficLight = "red"; if (trafficLight === "green") { drive(); } else if (trafficLight === "orange") { speedUp(); } else if (trafficLight === "red") { brakeHard(); } else { // if the trafficLight isn't green, orange or red. ask("Why is the traffic light not working?"); } ``` ## Loops -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -61,7 +61,7 @@ var zacharyFraser = { ### If Statement ``` if (condition) { doWhatever(); } ``` **condition:** What you are checking. @@ -70,30 +70,30 @@ if (condition) { ### If & Else Statement ``` if (condition) { doWhatever(); } else { doThisInstead(); } ``` ### If & ElseIf & Else Statement ``` if (condition) { doWhatever(); } else if (condition2) { doWhateverInstead(); } else { doThisInstead(); } ``` _Example:_ ``` var hungry = true; if (hungry === true) { eatFood(); } else if (hungry === false) { burp(); } ``` ## Loops -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -111,7 +111,8 @@ for ( x = 0 ; x < 10 ; x++ ) { ``` Here we start `x` at **0**, this will loop while `x` is less than or equal to (`<=`) **10**. Each time the loop goes through it will call `console.log("We are on loop: " + (x+1));` which outputs: "**We are on loop: 1**" the first time because `x` is **0** and we have specified it to show `x + 1`. Then it will increment `x` as we have specified earlier ( `x++` ). This loop should output: -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -109,10 +109,14 @@ for ( x = 0 ; x < 10 ; x++ ) { console.log("We are on loop: " + (x + 1)); } ``` Here we start `x` at **0**, this will loop while `x` is less than or equal to (`<=`) **10**. Each time the loop goes through it will call `console.log("We are on loop: " + (x+1));` which outputs: **We are on loop: 1** the first time (because `x` is **0** and we have specified it to show `x + 1`. Then it will increment `x` as we have specified earlier ( `x++` ). This loop should output: _We are on loop: 1_ _We are on loop: 2_ ... _We are on loop: 9_ _We are on loop: 10_ -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -95,4 +95,24 @@ if (hungry === true) { } else if (hungry === false) { doWhateverInstead; } ``` ## Loops ### For loop ``` for ( initalize ; conditiontoloop ; lastexpression ) { doStuff; } ``` _Example:_ ``` for ( x = 0 ; x < 10 ; x++ ) { console.log("We are on loop: " + (x + 1)); } ``` Here we start `x` at **0**, this will loop while `x` is less than or equal to (`<=`) **10**. Each time the loop goes through it will call `console.log("We are on loop: " + (x+1));` which outputs: **We are on loop: 1** the first time (because `x` is **0** and we have specified it to show `x + 1`. Then it will increment `x` as we have specified earlier ( `x++` ). This loop should output: **We are on loop: 1** **We are on loop: 2** ... **We are on loop: 9** **We are on loop: 10** -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -54,7 +54,7 @@ var zacharyFraser = { * `name:` which is using our variable `firstName` that was created on line 2. * `age: ` which is using our variable `age` that was created on line 1. * `isWeird: ` that we have set to `true` ourselves. * `catchPhrases: ` which is an array of all his favourite catchphrases. **Note:** We have not used any semicolons when defining these elements, this is because they are seperated just like an array, with commas. (Refer back to the shoebox analogy located in the tips above.) # Control Flow Statements -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,12 +39,23 @@ var age = 32; // 1. var firstName = "Zac"; // 2. var isWeird = true; // 3. var catchPhrases = ["Cya insertlastnamehere.", "Rob's the best."]; // 4. var zacharyFraser = { name: firstName, age: age, isWeird: true, catchPhrases: ["Cya insertlastnamehere.", "Rob's the best."] }; ``` 1. This creates a variable named **age** with a `number` value of **32**. 2. This creates a variable named **firstName** with a `string` value of **Zac**. 3. This creates a variable named **isWeird** with a `boolean` value of **true**. 4. This creates an array named **catchPhrases** with `string` elements: **"Cya insertlastnamehere."** and **"Rob's the best."** 5. This creates an object named **zacharyFraser** which contains his: * `name:` which is using our variable `firstName` that was created on line 2. * `age: ` which is using our variable `age` that was created on line 1. * `isWeird: ` that we have set to `true` ourselves. * `catchPhrases: ` which is an array of all his favourite catchphrases. **Note:** We have not used any semicolons when defining these elements, this is because they are seperated just like an array, with commas. (Refer back to the shoebox analogy located in the tips above.) # Control Flow Statements ### If Statement -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 15 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,9 @@ Here are some notes I've made to help you guys with your syntax. Think of it like a "cheatsheet". Some tips to remember: * Keep an eye on semicolons, usually control flow blocks (`if` blocks, `for, while` loops etc.) do not need a semicolon. * Keep an eye on your opening and closing brackets ( `{ & }` ). * Keep an eye on quotation marks. Match doubles with doubles ( `"` ), singles with singles ( `'` ). * **Also:** Watch when you're using apostrophes inside strings: ` var sentence = "You're weird"; `. Make sure you don't do this: ` var sentence = 'You're weird'; ` This will give you errors. * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine your conditions. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` @@ -31,8 +34,17 @@ _Objects_: **value:** The actualy item you want to put in your object. _Example:_ ``` var age = 32; // 1. var firstName = "Zac"; // 2. var isWeird = true; // 3. var catchPhrases = ["Cya insertlastnamehere.", "Rob's the best."]; // 4. ``` 1. This creates a variable named **age** with a `number` value of **32**. 2. This creates a variable named **firstName** with a `string` value of **Zac**. 3. This creates a variable named **isWeird** with a `boolean` value of **true**. 4. This creates an array named **catchPhrases** with `string` elements: **"Cya insertlastnamehere."** and **"Rob's the best."** # Control Flow Statements ### If Statement @@ -41,7 +53,7 @@ if (condition) { doWhatever; } ``` **condition:** What you are checking. **doWhatever;:** What you want to do if the check is `true`. ### If & Else Statement -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,6 +41,8 @@ if (condition) { doWhatever; } ``` **condition:** What you are checking. **doWhatever;:** What you want to do if the check is `true`. ### If & Else Statement ``` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine your conditions. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` * Arrays and Objects: * Think of an Array like a shoe closet, it holds many different shoes. * An Object is like a shoe closet, except each shoe has a shoebox with labels stuck on them. (Analogy from Lucy Bain. @lucykbain) -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,8 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` * Arrays and Objects. * Think of an Array like a shoe closet, it holds many different shoes. * An Object is like a shoe closet, except each shoe has a shoebox with labels stuck on them. (Analogy from Lucy Bain. @lucykbain) # Variables ``` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,9 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine your conditions. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` * Arrays and Objects. * Think of an Array like a shoe closet, it holds many different shoeboxes. * An Object is like a shoe closet, except each shoebox has different labels stuck on them. (Analogy from Lucy Bain. @lucykbain) # Variables ``` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,11 +21,11 @@ var variableName = { // Objects **variableName:** The name for your variable. **value:** The value you want to assign to your variable. _Arrays_: **element:** The item you want to put into the array (collection). _Objects_: **key:** The "label" you wish to give to your item. **value:** The actualy item you want to put in your object. _Example:_ -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,11 +8,26 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik # Variables ``` var variableName = value; // Numbers, Booleans var variableName = "value"; // Strings var variableName = [element, element]; // Arrays var variableName = { // Objects key: value, key: value }; ``` **variableName:** The name for your variable. **value:** The value you want to assign to your variable. _Arrays_: **element:** The item you want to put into the array (collection). _Objects_: **key:** The "label" you wish to give to your item. **value:** The actualy item you want to put in your object. _Example:_ ` var age = 32 ` This creates a variable named **age** with a value of **32**. -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -52,7 +52,5 @@ if (hungry === true) { eatFood; } else if (hungry === false) { doWhateverInstead; } ``` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,14 +18,14 @@ _Example:_ This creates a variable named **age** with a value of **32**. # Control Flow Statements ### If Statement ``` if (condition) { doWhatever; } ``` ### If & Else Statement ``` if (condition) { doWhatever; @@ -34,7 +34,7 @@ if (condition) { } ``` ### If & ElseIf & Else Statement ``` if (condition) { doWhatever; -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,6 +24,7 @@ if (condition) { doWhatever; } ``` ## If & Else Statement ``` if (condition) { @@ -32,6 +33,7 @@ if (condition) { doThisInstead; } ``` ## If & ElseIf & Else Statement ``` if (condition) { @@ -42,6 +44,7 @@ if (condition) { doThisInstead; } ``` _Example:_ ``` var hungry = true; -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ Here are some notes I've made to help you guys with your syntax. Think of it like a "cheatsheet". Some tips to remember: * Keep an eye on semicolons, usually control flow blocks (`if` blocks, `for, while` loops etc.) do not need a semicolon. * Keep an eye on your opening and closing brackets ( `{ & }` ). * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine your conditions. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,8 @@ Here are some notes I've made to help you guys with your syntax. Think of it lik * Keep an eye on semicolons, usually control flow blocks (`if` blocks, `for, while` loops etc.) do not need a semicolon. * Keep an eye on your opening and closing brackets ( `{ & }` ). * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine comparisons. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` * _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` # Variables -
robinsonlam revised this gist
Aug 8, 2015 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,8 @@ Here are some notes I've made to help you guys with your syntax. Think of it like a "cheatsheet". Some tips to remember: * Keep an eye on semicolons, usually control flow blocks (`if` blocks, `for, while` loops etc.) do not need a semicolon. * Keep an eye on your opening and closing brackets ( `{ & }` ). * When checking conditions with logical operators ( `&&, ||, !` ), you cannot combine comparisons. * _Incorrect:_ ` if ( chicken === yummy && tasty ) ` _Correct:_ ` if ( (chicken === yummy) && (chicken === tasty) ) ` # Variables @@ -38,4 +40,15 @@ if (condition) { } else { doThisInstead; } ``` _Example:_ ``` var hungry = true; if (hungry === true) { eatFood; } else if (hungry === false) { doWhateverInstead; } else { doThisInstead; } ```
NewerOlder