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 characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |
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 characters
| var myPlants = [ | |
| { | |
| type: "flowers", | |
| list: [ | |
| "rose", | |
| "tulip", | |
| "dandelion" | |
| ] | |
| }, | |
| { |
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 characters
| var myArray = []; | |
| for(var i = 1; i<6; i++){ // Start counting from 1, in order not to get 0, 1, 2, 3 | |
| myArray.push(i); | |
| }; | |
| myArray = [1,2,3,4,5]; |
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 characters
| // Example | |
| var ourArray = []; | |
| for (var i = 0; i < 10; i += 2) { | |
| ourArray.push(i); | |
| } | |
| /*ourArray will now contain [0,2,4,6,8]. - Почему не десяти, потому, что меньше десяти, а ближайшее число меньше десяти на двойку, на которую мы увеличиваем - это 8*/ |
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 characters
| // Example | |
| var ourArray = []; | |
| for (var i = 10; i > 0; i -= 2) { | |
| ourArray.push(i); | |
| } | |
| //[10,8,6,4,2] |
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 characters
| //Setup | |
| var contacts = [ | |
| { | |
| "firstName": "Akira", | |
| "lastName": "Laine", | |
| "number": "0543236543", | |
| "likes": ["Pizza", "Coding", "Brownie Points"] | |
| }, | |
| { |
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 characters
| var Car = function() { | |
| // this is a private variable | |
| var speed = 10; | |
| // these are public methods | |
| this.accelerate = function(change) { | |
| speed += change; | |
| }; |
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 characters
| var oldArray = [1,2,3]; | |
| var newArray = []; | |
| var concatMe = [4,5,6]; | |
| // Only change code below this line. | |
| newArray = oldArray.concat(concatMe); |
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 characters
| var joinMe = ["Split","me","into","an","array"]; | |
| var joinedString = ''; | |
| // Only change code below this line. | |
| joinedString = joinMe.join(" "); |
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 characters
| function slasher(arr, howMany) { | |
| return arr.slice(howMany); | |
| } | |
| slasher([1, 2, 3], 2); |
OlderNewer