diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index 4cfa6ef044..5e740784d4 100644 --- a/challenges/basic-javascript.json +++ b/challenges/basic-javascript.json @@ -7,7 +7,7 @@ "id": "bd7123c9c441eddfaeb4bdef", "title": "Comment your JavaScript Code", "description": [ - "Comments are lines of code that your computer will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what it does.", + "Comments are lines of code that your computer will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.", "Let's take a look at the two ways you can write comments in JavaScript.", "The double-slash comment will comment out the remainder of the text on the current line:", "// This is a comment.", @@ -30,7 +30,7 @@ "description": [ "In computer science, data structures are things that hold data. JavaScript has seven of these. For example, the Number data structure holds numbers.", "Let's learn about the most basic data structure of all: the Boolean. Booleans can only hold the value of either true or false. They are basically little on-off switches.", - "Let's modify our welcomeToBooleans function so that it will return true instead of falsewhen the run button is clicked." + "Let's modify our welcomeToBooleans function so that it will return true instead of false when the run button is clicked." ], "tests": [ "assert(typeof(welcomeToBooleans()) === 'boolean', 'message: The welcomeToBooleans() function should return a boolean (true/false) value.');", @@ -88,7 +88,6 @@ "assert((function(){if(typeof(myLastName) !== \"undefined\" && typeof(myLastName) === \"string\" && myLastName.length > 0){return true;}else{return false;}})(), 'message: myLastName should be a string with at least one character in it.');" ], "challengeSeed": [ - "var name = \"Alan Turing\";", "var firstName = \"Alan\";", "var lastName = \"Turing\";", "", @@ -141,11 +140,11 @@ "Bracket notation is a way to get a character at a specific index 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 \"Charles\" is \"C\". So if var firstName = \"Charles\", you can get the value of the first letter of the string by using firstName[0].", - "Use bracket notation to find the first character in the firstLetterOfLastName variable.", + "Use bracket notation to find the first character in the lastName variable and assign it to firstLetterOfLastName.", "Try looking at the firstLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert((function(){if(typeof(firstLetterOfLastName) !== \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return true;}else{return false;}})(), 'message: The first letter of firstLetterOfLastName should be a \"L\".');" + "assert((function(){if(typeof(firstLetterOfLastName) !== \"undefined\" && editor.getValue().match(/\\[0\\]/gi) && typeof(firstLetterOfLastName) === \"string\" && firstLetterOfLastName === \"L\"){return true;}else{return false;}})(), 'message: The firstLetterOfLastName variable should have the value of L.');" ], "challengeSeed": [ "var firstLetterOfFirstName = \"\";", @@ -177,7 +176,7 @@ "Try looking at the secondLetterOfFirstName variable declaration if you get stuck." ], "tests": [ - "assert(thirdLetterOfLastName === 'v', 'message: The third letter of lastName should be a \"v\".');" + "assert(thirdLetterOfLastName === 'v', 'message: The thirdLetterOfLastName variable should have the value of v.');" ], "challengeSeed": [ "var firstName = \"Ada\";", @@ -230,7 +229,7 @@ "id": "bd7123c9c452eddfaeb5bdef", "title": "Use Bracket Notation to Find the Nth-to-Last Character in a String", "description": [ - "In order to get the last letter of a string, you can subtract one from the string's length.", + "You can use the same principle we just used to retrieve the last character in a string to retrieve the Nth-to-last character.", "For example, you can get the value of the third-to-last letter of the var firstName = \"Charles\" string by using firstName[firstName.length - 3]", "Use bracket notation to find the second-to-last character in the lastName string.", "Try looking at the thirdToLastLetterOfFirstName variable declaration if you get stuck." @@ -525,7 +524,7 @@ "title": "Manipulate Arrays With pop()", "description": [ "Another way to change the data in an array is with the .pop() function.", - ".pop()is used to \"pop\" a value off of the end of an array. We can store this \"popped off\" variable by performing pop() within a variable declaration.", + ".pop() is used to \"pop\" a value off of the end of an array. We can store this \"popped off\" variable by performing pop() within a variable declaration.", "Any type of data structure can be \"popped\" off of an array - numbers, strings, even nested arrays.", "Use the .pop() function to remove the last item from myArray, assigning the \"popped off\" value to removedFromMyArray." ], @@ -662,7 +661,7 @@ "Create and call a function called myFunction that returns the sum of a and b." ], "tests": [ - "assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'message: Your function should return the value of a + b');" + "assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'message: Your function should return the value of a + b.');" ], "challengeSeed": [ "var a = 4;", @@ -772,6 +771,10 @@ " \"friends\": [\"Free Code Camp Campers\"]", "};", "", + "// Only change code below this line.", + "", + "", + "", "// Only change code above this line.", "", "(function(z){return z;})(myDog);" @@ -868,26 +871,26 @@ "You can run the same code multiple times by using a loop.", "The most common type of JavaScript loop is called a \"for loop\" because it runs \"for\" a specific number of times.", "For loops are declared with three optional expressions seperated by semicolons:", - "for([initialization]; [condition]; [final-expression])", + "for ([initialization]; [condition]; [final-expression])", "The initialization statement is executed one time only before the loop starts. It is typically used to define and setup your loop variable.", "The condition statement is evaluated at the beginning of every loop iteration and will continue as long as it evalutes to true. When condition is false at the start of the iteration, the loop will stop executing. This means if condition starts as false, your loop will never execute.", "The final-expression is executed at the end of each loop iteration, prior to the next condition check and is usually used to increment or decrement your loop counter.", "In the following example we initialize with i = 0 and iterate while our condition i < 5 is true. We'll increment i by 1 in each loop iteration with i++ as our final-expression.", "var ourArray = [];", - "for(var i = 0; i < 5; i++) {", + "for (var i = 0; i < 5; i++) {", "  ourArray.push(i);", "}", "ourArray will now contain [0,1,2,3,4].", - "Let's try getting a for loop to work by pushing values to an array." + "Let's use a for loop to work to push the values 1 through 5 onto myArray." ], "tests": [ "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4]');" + "assert.deepEqual(myArray, [1,2,3,4,5], 'message: myArray should equal [1,2,3,4,5].');" ], "challengeSeed": [ "var ourArray = [];", "", - "for(var i = 0; i < 5; i++){", + "for (var i = 0; i < 5; i++) {", " ourArray.push(i);", "}", "", @@ -912,21 +915,21 @@ "For loops don't have to iterate one at a time. By changing our final-expression, we can count by even numbers.", "We'll start at i = 0 and loop while i < 10. We'll increment i by 2 each loop with i += 2.", "var ourArray = [];", - "for(var i = 0; i < 10; i += 2) {", + "for (var i = 0; i < 10; i += 2) {", "  ourArray.push(i);", "}", - "ourArray will now contain [0,2,4,6,8] ", + "ourArray will now contain [0,2,4,6,8].", "Let's change our initialization and final-expression so we can count by odd numbers.", - "Push the odd numbers from 1 through 9 to myArray using a for loop." + "Push the odd numbers from 1 through 9 to myArray using a for loop." ], "tests":[ "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", - "assert.deepEqual(myArray, [1,3,5,7,9], 'message: myArray should equal [1,3,5,7,9]');" + "assert.deepEqual(myArray, [1,3,5,7,9], 'message: myArray should equal [1,3,5,7,9].');" ], "challengeSeed":[ "var ourArray = [];", "", - "for(var i = 0; i < 10; i += 2){", + "for (var i = 0; i < 10; i += 2) {", " ourArray.push(i);", "}", "", @@ -952,21 +955,21 @@ "In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.", "We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.", "var ourArray = [];", - "for(var i = 10; i > 0; i -= 2) {", + "for (var i = 10; i > 0; i -= 2) {", "  ourArray.push(i);", "}", - "ourArray will now contain [10,8,6,4,2]", + "ourArray will now contain [10,8,6,4,2].", "Let's change our initialization and final-expression so we can count backward by twos for numbers.", - "Push the odd numbers from 9 through 1 to myArray using a for loop." + "Push the odd numbers from 9 through 1 to myArray using a for loop." ], "tests":[ "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", - "assert.deepEqual(myArray, [9,7,5,3,1], 'message: myArray should equal [9,7,5,3,1]');" + "assert.deepEqual(myArray, [9,7,5,3,1], 'message: myArray should equal [9,7,5,3,1].');" ], "challengeSeed":[ "var ourArray = [];", "", - "for(var i = 10; i > 0; i -= 2){", + "for (var i = 10; i > 0; i -= 2) {", " ourArray.push(i);", "}", "", @@ -997,11 +1000,11 @@ "  i++;", "}", "Let's try getting a while loop to work by pushing values to an array.", - "Push the numbers 0 through 4 to myArray using a while loop." + "Push the numbers 0 through 4 to myArray using a while loop." ], "tests": [ "assert(editor.getValue().match(/while/g), 'message: You should be using a while loop for this.');", - "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4]');" + "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], "challengeSeed": [ "var myArray = [];", @@ -1071,7 +1074,7 @@ "challengeSeed": [ "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);", "", - "function myFunction(){", + "function myFunction() {", "", " // Only change code below this line.", "", @@ -1093,7 +1096,7 @@ "To do this, we'll define a minimum number min and a maximum number max.", "Here's the formula we'll use. Take a moment to read it and try to understand what this code is doing:", "Math.floor(Math.random() * (max - min + 1)) + min", - "Define two variables: myMin and myMax, and set them both equal to numbers.", + "Define two variables: myMin and myMax, and set them both equal to numbers.", "Then create a function called myFunction that returns a random number that's greater than or equal to myMin, and is less than or equal to myMax." ], "tests": [ @@ -1212,7 +1215,7 @@ "title": "Find Numbers with Regular Expressions", "description": [ "We can use special selectors in Regular Expressions to select a particular type of value.", - "One such selector is the digit selector \\d which is used to grab the numbers in a string.", + "One such selector is the digit selector \\d which is used to retrieve the numbers in a string.", "It is used like this: /\\d/g.", "For numbers this is often written as /\\d+/g, where the + following the digit selector allows this regular expression to match multi-digit numbers.", "Use the \\d selector to select the number of numbers in the string, allowing for the possibility of multi-digit numbers." @@ -1316,7 +1319,7 @@ ], "challengeSeed": [ "fccss", - " function runSlots(){", + " function runSlots() {", " var slotOne;", " var slotTwo;", " var slotThree;", @@ -1332,14 +1335,14 @@ " $(\".logger\").html(\"\");", " $(\".logger\").html(\"Not A Win\")", " ", - " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", + " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {", " $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);", " }", " return [slotOne, slotTwo, slotThree];", " }", "", - " $(document).ready(function(){", - " $(\".go\").click(function(){", + " $(document).ready(function() {", + " $(\".go\").click(function() {", " runSlots();", " });", " });", @@ -1460,7 +1463,7 @@ "Otherwise, we should return null, which is a JavaScript data structure that means nothing.", "If all three numbers match, we should return the number that we have in three of slots or leave it as null.", "Let's create an if statement with multiple conditions in order to check whether all numbers are equal.", - "if(slotOne !== slotTwo || slotTwo !== slotThree){", + "if (slotOne !== slotTwo || slotTwo !== slotThree) {", "  return null;", "}" ], @@ -1469,7 +1472,7 @@ ], "challengeSeed": [ "fccss", - " function runSlots(){", + " function runSlots() {", " var slotOne;", " var slotTwo;", " var slotThree;", @@ -1489,7 +1492,7 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", + " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {", " $(\".logger\").html(slotOne);", " $(\".logger\").append(\" \" + slotTwo);", " $(\".logger\").append(\" \" + slotThree);", @@ -1497,8 +1500,8 @@ " return [slotOne, slotTwo, slotThree];", " }", "", - " $(document).ready(function(){", - " $(\".go\").click(function(){", + " $(document).ready(function() {", + " $(\".go\").click(function() {", " runSlots();", " });", " });", @@ -1627,7 +1630,7 @@ ], "challengeSeed": [ "fccss", - " function runSlots(){", + " function runSlots() {", " var slotOne;", " var slotTwo;", " var slotThree;", @@ -1651,7 +1654,7 @@ " return slotOne;", " }", " ", - " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", + " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {", " $(\".logger\").html(slotOne);", " $(\".logger\").append(\" \" + slotTwo);", " $(\".logger\").append(\" \" + slotThree);", @@ -1660,8 +1663,8 @@ " return [slotOne, slotTwo, slotThree];", " }", "", - " $(document).ready(function(){", - " $(\".go\").click(function(){", + " $(document).ready(function() {", + " $(\".go\").click(function() {", " runSlots();", " });", " });", @@ -1796,7 +1799,7 @@ ], "challengeSeed": [ "fccss", - " function runSlots(){", + " function runSlots() {", " var slotOne;", " var slotTwo;", " var slotThree;", @@ -1820,7 +1823,7 @@ " return slotOne;", " }", " ", - " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", + " if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {", " $('.logger').html(slotOne);", " $('.logger').append(' ' + slotTwo);", " $('.logger').append(' ' + slotThree);", @@ -1829,8 +1832,8 @@ " return [slotOne, slotTwo, slotThree];", " }", "", - " $(document).ready(function(){", - " $('.go').click(function(){", + " $(document).ready(function() {", + " $('.go').click(function() {", " runSlots();", " });", " });", diff --git a/challenges/jquery.json b/challenges/jquery.json index d96a3df286..43f7b26843 100644 --- a/challenges/jquery.json +++ b/challenges/jquery.json @@ -161,7 +161,7 @@ "$(\"#target6\").addClass(\"animated fadeOut\")." ], "tests": [ - "assert($(\"#target3\").hasClass(\"animated\"), 'Select the buttonelement with the id of target3 and use the jQuery addClass() function to give it the class of animated.')", + "assert($(\"#target3\").hasClass(\"animated\"), 'Select the button element with the id of target3 and use the jQuery addClass() function to give it the class of animated.')", "assert(($(\"#target3\").hasClass(\"fadeOut\") || $(\"#target3\").hasClass(\"fadeout\")) && editor.match(/\\$\\(.#target3.\\)/g), 'Target the element with the id target3 and use the jQuery addClass() function to give it the class fadeOut.')", "assert(!editor.match(/class.*animated/g), 'Only use jQuery to add these classes to the element.')" ],