"A comment is a very useful line of code that is not actually ran by the machine executing it. With this property comments are the perfect way of creating notes to yourself or anyone else who reads your code describing what the code does",
"It's an extremely important part in writing good, efficient and maintainable code and a requirement by most employers",
"Let's take a look at the two ways in which we can write a comment in JavaScript",
"<code> //This is a comment </code>",
"These comment out the entire line that they are on",
"<code> /*This also is a comment*/ </code>",
"These comment out everything in between <code> /* </code> and <code> */ </code>",
"Try creating one of each now."
],
"tests":[
"assert(editor.getValue().match(/(\\/\\*)...../g), 'Make sure you have at least one \/\\* \\*\/ style comment that has at least three letters in it');",
"assert(editor.getValue().match(/(\\*\\/)/g), 'Make sure that you close the coment with a \\*\/');",
"assert(editor.getValue().match(/(\\/\\/)...../g), 'Make sure that there is at least one \\/\\/ style comment with at least three letters in it');"
"A boolean is a type of variable that represents either true or false (Named after the British mathematician George Boole).",
"Booleans are often the result of a function or a comparative operation, for example <code> 1==1 </code> is true whereas <code> 1==2 </code> is false.",
"They are most commonly found inside <code> if </code> statements which we shall cover later",
"For now Let's modify our <code> welcomeToBooleans </code> function so that it will return <code> true </code> instead of <code> false </code> when the run button is clicked"
"Now, use the <code>var</code> keyword to create a <code>variable</code> called <code>myName</code>. Set its value to your name.",
"<code>Variables</code> are used to store values.",
"The name variable comes from the fact that it's value, varies!",
"Now Let's create our first variable called myName and because it's a name let's make it a string!",
"Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in <code>camel case</code>. An example of camel case is: camelCase.",
"Be sure to use lowercase and uppercase letters properly. JavaScript variables are written in <code>lower camel case</code>. An example of lower camel case is: lowerCamelCase.",
"Look at the <code>ourName</code> example if you get stuck."
"Use the <code>.length</code> property to count the number of characters in the <code>lastNameLength</code> variable.",
"For example, if we created a variable <code>var firstName = \"Julie\"</code>, we could find out how long the string \"Julie\" is by using the <code>firstName.length</code> property."
"Use <code>bracket notation</code> to find the first character in a the <code>firstLetterOfLastName</code> variable.",
"<code>Bracket notation</code> is a way to get a character at a specific <code>index</code> within a string.",
"Computers don't start counting at 1 like humans do. They start at 0.",
"For example, the character at index 0 in the word \"Julie\" is \"J\". So if <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"Try looking at the <code>firstLetterOfFirstName</code> variable declaration if you get stuck."
"Just like the last lesson where we used <code> Bracket Notation </code> to access the first letter we can use the same method to get the letters ar other positions",
"Don't forget that computers start counting at 0 so the first letter is actually the zeroth one",
"Let's now try to set <code> thirdLetterOfLastName </code> to equal the third letter of the <code> lastName </code> variable",
"Use <code>bracket notation</code> to find the last character in the <code>lastName</code> variable.",
"For example, the character at index 0 in the word \"Julie\" is \"J\". So if <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"In order to get the last letter of a string, you can subtract one from the string's length.",
"For example, if <code>var firstName = \"Julie\"</code>, you can get the value of the last letter of the string by using <code>firstName[firstName.length - 1]</code>.",
"Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck."
"Use <code>bracket notation</code> to find the second-to-last character in the <code>lastName</code> variable.",
"For example, the character at index 0 in the word \"Julie\" is \"J\". So if <code>var firstName = \"Julie\"</code>, you can get the value of the first letter of the string by using <code>firstName[0]</code>.",
"In order to get the last letter of a string, you can subtract one from the string's length.",
"For example, if <code>var firstName = \"Julie\"</code>, you can get the value of the third-to-last letter of the string by using <code>firstName[firstName.length - 3]</code>.",
"Try looking at the <code>lastLetterOfLastName</code> variable declaration if you get stuck."
"In JavaScript we can store lists or collections of data in what are called arrays",
"Arrays are distinguished by the <code> [ </code> and <code> ] </code> around the data. Each piece of data is separated be a <code> , </code>",
"Now let's create a new array called <code> myArray </code> with a <code> string </code>, a <code> number </code> and a <code> array </code> with a <code> , </code> separating each one",
"Refer to the example if you get stuck",
""
],
"tests":[
"assert(typeof(myArray) == 'object', 'myArray should be an array');",
"assert(myArray[0] !== undefined && typeof(myArray[0]) == 'string', 'The fist item in myArray should be a string');",
"assert(myArray[1] !== undefined && typeof(myArray[1]) == 'number', 'The second item in myArray should be a number');",
"assert(myArray[2] !== undefined && typeof(myArray[2]) == 'object', 'The third item in myArray should be an array');"
"When and array has been defined we still have the ability to make changes to it afterwards",
"One common way in which we can manipulate the data in an array is through <code> .pop() </code>",
"<code> .pop() </code> is used to \"pop\" a value from the end of an array. We can retrieve this value by preforming the pop in a variable declaration.",
"any type of variable can be \"popped\" from and array",
"Let's try <code> .pop() </code> now"
],
"tests":[
"assert((function(d){if(d[0] == 'John' && d[1] == 23 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');",
"assert((function(d){if(d[0] == 'cat' && d[1] == 2 && d[2] == undefined){return(true);}else{return(false);}})(removed), 'myArray should only have the first two values left([\"cat\"], 2)');"
],
"challengeSeed":[
"//var numbers = [1,2,3];",
"//console.log(numbers); //Gives [1,2,3]",
"//var removed = numbers.pop();",
"//console.log(numbers); //Gives [1,2]",
"//console.log(removed); //Gives 3",
"",
"var myArray = ['John', 23, ['cat', 2]];",
"var removed = _;//This should be ['cat', 2] and myArray should now be ['John', 23]",
"Another common way in which we can manipulate the data in an array is through <code> .shift() </code>",
"<code> .shift() </code> is used to \"shift\" a value from the start of an array. We can retrieve this value by preforming the shift in a variable declaration.",
"Let's try <code> .shift() </code> now"
],
"tests":[
"assert((function(d){if(d[0] == 23 && d[1][0] == 'dog' && d[1][1] == 3 && d[2] == undefined){return(true);}else{return(false);}})(myArray), 'myArray should only have the first two values left([\"John\", 23])');",
"assert((function(d){if(d == 'John'){return(true);}else{return(false);}})(removed), 'Removed should contain \"John\"');"
],
"challengeSeed":[
"var myArray = ['John', 23, ['dog', 3]];",
"var removed = _;//This should be ['John'] and myArray should now be ['John', 23]",
"Now that we've learned how to <code> shift </code> things from the start of the array, we need to learn how to <code> unshift </code> stuff back to the start",
"Let's take the code we had last time and <code> unshift </code> this value to the end: <code> 'Paul' </code>"
"With Arrays, we can access and modify the data inside them using indexes much like we did with strings. The major difference between using indexes with arrays versus using them in strings is that you cannot modify data in a string using and index.",
"In Arrays though we are freely allowed to change values in an array.",
"Let's have a go and accessing the <code> last </code> item in myArray and changing the middle value tp <code> 25 </code>",
"Take a look at the commented out example above if you get stuck"
"assert((function(l){if(l[0] != undefined && l[0] == 'dog' && l[1] != undefined && l[1] == 3){return(true);}else{return(false);}})(last), 'The last variable in myArray should be [\"dog\", 3]');"
],
"challengeSeed":[
"//var ourArray = ['Alpha', 'Beta', 'Gamma'];",
"//ourArray[0];//the first item in the array is 'Alpha'",
"//ouArray[1] = 'Omega';//The second item int the array is nom Omega instead of Beta",
"",
"var myArray = ['Paul', 23, ['dog', 3]];",
"var last = _;//Set this to be the last variable in the array using an index",
"",
"//Now set the second item in the Array to be 25 using an index'",
"A function that takes the value you give it and returns it isn't very useful! So now let's get our functions to do something!",
"Starting from where we were last time let's make our function revers whatever we give it by chaining <code> .split('') </code>, <code> .reverse() </code> and <code> .join('') </code>"
],
"tests":[
"assert(f==data.split('').reverse().join(''), 'myFunction should now return the reversed version of data (!dellaC noitcnuF)');"
"A very important data type in javascript is the <code> Object </code>",
"<code> Objects </code> a similar to <code> arrays </code> except that instead of using indexes to access and modify their data, Objects have what are called <code> properties </code>",
"Here's a sample Object",
"<code>",
"var cat = {",
" \"name\": \"Whiskers\",",
" \"legs\": 4,",
" \"tails\": 1,",
" \"enemies\": [\"Water\", \"Dogs\"]",
"};",
"</code>",
"Objects are useful for storing data in a structured way or in a way that represents a real world object like a cat.",
"Let's try to make a Object that represents a dog called myDog!"
],
"tests":[
"assert((function(z){if(z.hasOwnProperty('name') && z.name != undefined && typeof(z.name) == 'string'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property name and it should be a string');",
"assert((function(z){if(z.hasOwnProperty('legs') && z.legs != undefined && typeof(z.legs) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property legs and it should be a number');",
"assert((function(z){if(z.hasOwnProperty('tails') && z.tails != undefined && typeof(z.tails) == 'number'){return(true);}else{return(false);}})(myDog), 'myDog should contain the property tails and it should be a number');",
"assert((function(z){if(z.hasOwnProperty('friends') && z.friends != undefined && Array.isArray(z.friends)){return(true);}else{return(false);}})(myDog), 'myDog should contain the property friends and it should be an array');"
],
"challengeSeed":[
"//var ourDog = {",
" //\"name\": \"Camper\"",
" //\"legs\": 4",
" //\"tails\": 1",
" //\"friends\": ['everything!']",
"//};",
"",
"/* add the name(string), legs(number), tails(number) and friends(array) properties to myDog.",