diff --git a/challenges/object-oriented-and-functional-programming.json b/challenges/object-oriented-and-functional-programming.json
index 86e33fd2d2..aad1e5756c 100644
--- a/challenges/object-oriented-and-functional-programming.json
+++ b/challenges/object-oriented-and-functional-programming.json
@@ -98,7 +98,7 @@
"Objects have their own attributes, called properties
, and their own functions, called methods
.",
"In the previous challenge, we used the this
keyword to reference public properties
and public methods
of the current object.",
"We can also create private properties
and private methods
, which aren't accessible from outside the object.",
- "To do this, we omit the word this
from the property
or method
declaration.",
+ "To do this, just declare properties or functions within the constructor.",
"Let's create an object with two functions. One attached as a property and one not.",
"See if you can keep myBike.speed
and myBike.addUnit
private, while making myBike.getSpeed
publicly accessible."
],
@@ -109,13 +109,13 @@
],
"challengeSeed":[
"var Car = function() {",
- "",
- " gear = 1;",
- "",
+ " // this is a private variable",
+ " var gear = 1;",
+ " // this is a private function (also known as a private method)",
" function addStyle(styleMe){",
" return 'The Current Gear Is: ' + styleMe;",
" }",
- "",
+ " // this is a public method",
" this.getGear = function() {",
" return addStyle(this.gear);",
" };",
@@ -144,7 +144,7 @@
"",
"var myBike = new Bike();",
"",
- "if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();};"
+ "if(myBike.hasOwnProperty('getSpeed')){(function() {return JSON.stringify(myBike.getSpeed());})();}"
],
"challengeType":1,
"type": "waypoint"
@@ -153,10 +153,10 @@
"id":"cf1111c1c15feddfaeb4bdef",
"title":"Make Instances of Objects with a Constructor Function",
"description":[
- "Sometimes you'll want to be able to easily create similar objects.",
+ "Sometimes you'll want to be able to easily create many copies of an objects that all share the same methods.",
"Objects have their own attributes, called properties
, and their own functions, called methods
.",
- "A function that creates objects is called a constructor
.",
"You can create instances
of an object using a constructor
.",
+ "A constructor is a function that creates instances of an object that share the same methods and properties",
"Each new instance
of this object inherits
all the properties
and methods
of your original object.",
"Once an instance
has been created you can add properties
to that instance
individually.",
"Add an engines
property with a number value to the myCar
instance."
@@ -227,11 +227,11 @@
"description":[
"The array method reduce
is used to iterate through an array and condense it into one value.",
"To use reduce
you pass in a callback whose arguments are an accumulator (in this case, previousVal
) and the current value (currentVal
).",
- "reduce
has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified if will be the first array element.",
- "Here is an example of reduce
being used to sum all the values of an array:",
+ "reduce
has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified it will be the first array element and currentVal will start with the second array element.",
+ "Here is an example of reduce
being used to subtract all the values of an array:",
"var singleVal = array.reduce(function(previousVal, currentVal) {
",
- " return previousVal+currentVal;
",
- "});
",
+ " return previousVal - currentVal;
",
+ "}, 0);
",
"Use the reduce
method to sum all the values in array
and assign it to singleVal
."
],
"tests":[
@@ -241,12 +241,10 @@
"challengeSeed":[
"var array = [4,5,6,7,8];",
"",
- "var singleVal = 0;",
"",
"// Only change code below this line.",
"",
- "",
- "",
+ "var singleVal = array;",
"",
"",
"",
@@ -265,29 +263,30 @@
"title":"Filter Arrays with .filter",
"description":[
"The filter
method is used to iterate through an array and filter out elements where a given condition is not true.",
- "filter
is passed a callback function which takes the current value (we've called that val
) as an argument. It can also use arguments for the index
and array
being acted on.",
+ "filter
is passed a callback function which takes the current value (we've called that val
) as an argument.",
"Any array element for which the callback returns true will be kept and elements that return false will be filtered out.",
"The following code is an example of using filter to remove array elements that are not even numbers:",
+ "Note: We omit the second and third arguments since we only need the value",
"array = array.filter(function(val) {
",
" return val % 2 === 0;
",
"});
",
"Use filter
to remove all elements from array
that are greater than 5."
],
"tests":[
- "assert.deepEqual(array, [1,2,3,4,5], 'message: You should have removed all the values from the array that are greater than 5.');",
+ "assert.deepEqual(newArray, [1,2,3,4,5], 'message: You should have removed all the values from the array that are greater than 5.');",
"assert(editor.getValue().match(/array\\.filter\\s*\\(/gi), 'message: You should be using the filter
method to remove the values from the array.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\,4\\,5\\,6\\,7\\,8\\,9\\,10\\]/gi), 'message: You should only be using filter
to modify the contents of the array.');"
],
"challengeSeed":[
- "var array = [1,2,3,4,5,6,7,8,9,10];",
+ "var oldArray = [1,2,3,4,5,6,7,8,9,10];",
"",
"// Only change code below this line.",
"",
- "",
+ "var newArray = oldArray;",
"",
"// Only change code above this line.",
"",
- "(function() {return array;})();"
+ "(function() { return newArray; })();"
],
"MDNlinks":[
"Array.filter()"
@@ -307,23 +306,23 @@
"array.sort(function(a, b) {
",
" return a - b;
",
"});
",
- "Use sort
to sort array
alphabetically."
+ "Use sort
to sort array
from largest to smallest."
],
"tests":[
- "assert.deepEqual(array, ['alpha', 'beta', 'charlie'], 'message: You should have sorted the array alphabetically.');",
- "assert(editor.getValue().match(/\\[\\'beta\\'\\,\\s\\'alpha\\'\\,\\s'charlie\\'\\];/gi), 'message: You should only be using sort
to modify the array.');",
- "assert(editor.getValue().match(/\\.sort\\s*\\(\\)/gi), 'message: You should have made use of the sort
method.');"
+ "assert.deepEqual(array, [21, 12, 2, 1], 'message: You should have sorted the array from largest to smallest.');",
+ "assert(editor.getValue().match(/\\[1,\\s*12,\\s*21,\\s*2\\];/gi), 'message: You should only be using sort
to modify the array.');",
+ "assert(editor.getValue().match(/\\.sort\\s*\\(/g), 'message: You should have made use of the sort
method.');"
],
"challengeSeed":[
- "var array = ['beta', 'alpha', 'charlie'];",
+ "var array = [1, 12, 21, 2];",
"",
"// Only change code below this line.",
"",
- "",
+ "array.sort();",
"",
"// Only change code above this line.",
"",
- "(function() {return array;})();"
+ "(function() { return array; })();"
],
"MDNlinks":[
"Array.sort()"
@@ -367,27 +366,27 @@
"description": [
"concat
can be used to merge the contents of two arrays into one.",
"concat
takes an array as an argument and returns a new array with the elements of this array concatenated onto the end.",
- "Here is an example of concat
being used to concatenate otherArray
onto the end of array
:",
- "array = array.concat(otherArray);
",
- "Use .concat()
to concatenate concatMe
onto the end of array
and assign it back to array
."
+ "Here is an example of concat
being used to concatenate otherArray
onto the end of oldArray
:",
+ "newArray = oldArray.concat(otherArray);
",
+ "Use .concat()
to concatenate concatMe
onto the end of oldArray
and assign it to newArray
."
],
"tests": [
- "assert.deepEqual(array, [1,2,3,4,5,6], 'message: You should concatenate the two arrays together.');",
+ "assert.deepEqual(newArray, [1,2,3,4,5,6], 'message: You should concatenate the two arrays together.');",
"assert(editor.getValue().match(/\\.concat\\s*\\(/gi), 'message: You should be using the concat
method to merge the two arrays.');",
"assert(editor.getValue().match(/\\[1\\,2\\,3\\]/gi) && editor.getValue().match(/\\[4\\,5\\,6\\]/gi), 'message: You should only be using concat
to modify the arrays.');"
],
"challengeSeed": [
- "var array = [1,2,3];",
+ "var oldArray = [1,2,3];",
"",
"var concatMe = [4,5,6];",
"",
"// Only change code below this line.",
"",
- "",
+ "var newArray = oldArray;",
"",
"// Only change code above this line.",
"",
- "(function() {return array;})();"
+ "(function() { return newArray; })();"
],
"MDNlinks":[
"Array.concat()"
@@ -401,8 +400,8 @@
"description":[
"You can use the split
method to split a string into an array.",
"split
uses the argument you pass in as a delimiter to determine which points the string should be split at.",
- "Here is an example of split
being used to split an array at every space character:",
- "var array = string.split(' ');
",
+ "Here is an example of split
being used to split an array at every s
character:",
+ "var array = string.split('s');
",
"Use split
to create an array of words from string
and assign it to array
."
],
"tests":[
@@ -431,8 +430,10 @@
"title":"Join Strings with .join",
"description":[
"We can use the join
method to join each element of an array into a string separated by whatever delimiter you provide as an argument.",
- "The following is an example of using join
to join all of the elements of an array into a string with all the elements seperated by a space:",
- "var joinedString = joinMe.join(\" \");
",
+ "The following is an example of using join
to join all of the elements of an array into a string with all the elements seperated by word `Na`:",
+ "var joinMe = [\"Na \", \"Na \", \"Na \", \"Na \", \"Batman!\"];
",
+ "var joinedString = joinMe.join(\"Na \");
",
+ "console.log(joinedString);
",
"Use the join
method to create a string from joinMe
with spaces in between each element and assign it to joinedString
."
],
"tests":[