diff --git a/challenges/02-javascript-algorithms-and-data-structures/es6.json b/challenges/02-javascript-algorithms-and-data-structures/es6.json
index d12880a8d9..8e72dfe0f3 100644
--- a/challenges/02-javascript-algorithms-and-data-structures/es6.json
+++ b/challenges/02-javascript-algorithms-and-data-structures/es6.json
@@ -38,17 +38,24 @@
"A new keyword called let
was introduced in ES6 to solve the problems with the var
keyword. With the let
keyword, all the examples we just saw will cause an error to appear. We can no longer overwrite variables or use a variable before we declare it. Some modern browsers require you to add \"use strict\";
to the top of your code before you can use the new features of ES6.",
"Let's try using the let
keyword.",
"
let
keyword and makes the errors go away."
+ "Replace var
with let
"
],
"challengeSeed": [
- "\"use strict\";",
- "var favorite = redNosedReindeer + \" is Santa's favorite reindeer.\";",
- "var redNosedReindeer = \"Rudolph\";",
- "var redNosedReindeer = \"Comet\";"
+ "var catName;",
+ "var quote;",
+ "function catTalk() {",
+ " \"use strict\";",
+ "",
+ " catName = \"Oliver\";",
+ " quote = catName + \" says Meow!\";",
+ "",
+ "}",
+ "catTalk();"
],
"tests": [
- "assert(redNosedReindeer === \"Rudolph\", 'message: redNosedReindeer
should be Rudolph.');",
- "assert(favorite === \"Rudolph is Santa's favorite reindeer.\", 'message: favorite
should return Santa's favorite reindeer.');"
+ "getUserInput => assert(!getUserInput('index').match(/var/g),'message: var
does not exist in code.');",
+ "assert(catName === \"Oliver\", 'message: catName
should be Oliver
.');",
+ "assert(quote === \"Oliver says Meow!\", 'message: quote
should be \"Oliver says Meow!\"
');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -75,8 +82,9 @@
"This exercise is designed to illustrate the difference between how var
and let
keywords assign scope to the declared variable. When programming a function similar to the one used in this exercise, it is often better to use different variable names to avoid confusion."
],
"challengeSeed": [
- "\"use strict\";",
+ "",
"function checkScope() {",
+ "\"use strict\";",
" var i = \"function scope\";",
" if (true) {",
" i = \"block scope\";",
@@ -84,12 +92,10 @@
" }",
" console.log(\"Function scope i is: \", i);",
" return i;",
- "}",
- "// only change the code above this line",
- "checkScope();"
+ "}"
],
"tests": [
- "// TEMPORARILY COMMENTED OUT: assert(!/var/g.test(code) && /let/g.test(code), 'message: The var
keyword should be replaced with let
. (This test is temporarily disabled)');",
+ "getUserInput => assert(!getUserInput('index').match(/var/g),'message: var
does not exist in code.');",
"getUserInput => assert(getUserInput('index').match(/(i\\s*=\\s*).*\\s*.*\\s*.*\\1('|\")block\\s*scope\\2/g), 'message: The variable i
declared in the if statement should equal \"block scope\".');",
"assert(checkScope() === \"function scope\", 'message: checkScope()
should return \"function scope\"');"
],
@@ -107,27 +113,28 @@
"\"use strict\"", "As you can see, trying to reassign a variable declared with
const FAV_PET = \"Cats\";
FAV_PET = \"Dogs\"; // returns error
const
will throw an error. You should always name variables you don't want to reassign using the const
keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice is to name your constants in all upper-cases and with an underscore to separate words (e.g. EXAMPLE_VARIABLE
).",
"let
or const
. Use let
when you want the variable to change, and const
when you want the variable to remain constant. Also, rename variables declared with const
to conform to common practices."
+ "Change the code so that all variables are declared using let
or const
. Use let
when you want the variable to change, and const
when you want the variable to remain constant. Also, rename variables declared with const
to conform to common practices, meaning constants should be in all caps"
],
"challengeSeed": [
- "\"use strict\";",
- "var pi = 3.14;",
- "var radius = 10;",
- "var calculateCircumference = function(r) {",
- " var diameter = 2 * r;",
- " var result = pi * diameter;",
- " return result;",
- "};",
- "// Test your code",
- "console.log(calculateCircumference(radius));",
- "radius = 5;",
- "console.log(calculateCircumference(radius));"
+ "function printManyTimes(str) {",
+ " \"use strict\";",
+ "",
+ " // change code below this line",
+ "",
+ " var sentence = str + \" is cool!\";",
+ " for(var i = 0; i < str.length; i+=2) {",
+ " console.log(str2);",
+ " }",
+ "",
+ " // change code above this line",
+ "",
+ "}",
+ "printManyTimes(\"FreeCodeCamp\");"
],
"tests": [
- "assert(!/var/g.test(code),'message: var
does not exist in code.');",
- "getUserInput => assert(getUserInput('index').match(/(const pi)/g), 'message: PI
is const
.');",
- "getUserInput => assert(getUserInput('index').match(/(const calculateCircumference)/g), 'message: calculateCircumference
is const
.');",
- "getUserInput => assert(getUserInput('index').match(/(let radius)/g), 'message: radius
is let
.');"
+ "getUserInput => assert(!getUserInput('index').match(/var/g),'message: var
does not exist in code.');",
+ "getUserInput => assert(getUserInput('index').match(/(const SENTENCE)/g), 'message: SENTENCE
should be a constant variable (by using const
).');",
+ "getUserInput => assert(getUserInput('index').match(/(let i)/g), 'message: i
should be a variable only defined within the for loop scope (by usinglet
).');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -147,19 +154,20 @@
"An array is declared as const s = [5, 7, 2]
. Change the array to [2, 5, 7]
using various element assignment."
],
"challengeSeed": [
- "\"use strict\";",
"const s = [5, 7, 2];",
- "// change code below this line",
+ "function editInPlace() {",
+ " \"use strict\";",
+ " // change code below this line",
"",
- "s = [2, 5, 7];",
+ " // s = [2, 5, 7]; <- this is invalid",
"",
- "// change code above this line",
- "// Test your code",
- "console.log(s);"
+ " // change code above this line",
+ "}",
+ "editInPlace();"
],
"tests": [
"getUserInput => assert(getUserInput('index').match(/const/g), 'message: Do not replace const
keyword.');",
- "getUserInput => assert(getUserInput('index').match(/const\\s+s/g), 'message: s
is declared with const
.');",
+ "getUserInput => assert(getUserInput('index').match(/const\\s+s/g), 'message: s
should be a constant variable (by using const
).');",
"getUserInput => assert(getUserInput('index').match(/const\\s+s\\s*=\\s*\\[\\s*5\\s*,\\s*7\\s*,\\s*2\\s*\\]\\s*;?/g), 'message: Do not change the original array declaration.');",
"assert.deepEqual(s, [2, 5, 7], 'message: s
should be equal to [2, 5, 7]
.');"
],
@@ -179,23 +187,29 @@
"In this challenge you are going to use Object.freeze
to prevent mathematical constants from changing. You need to freeze MATH_CONSTANTS
object so that noone is able alter the value of PI
or add any more properties to it."
],
"challengeSeed": [
- "\"use strict\";",
- "const MATH_CONSTANTS = {",
- " PI: 3.14",
- "};",
- "// change code below this line",
+ "function freezeObj() {",
+ " \"use strict\";",
+ " const MATH_CONSTANTS = {",
+ " PI: 3.14",
+ " };",
+ " // change code below this line",
"",
"",
- "// change code above this line",
- "MATH_CONSTANTS.PI = 99;",
- "// Test your code",
- "console.log(MATH_CONSTANTS.PI);// should show 3.14"
+ " // change code above this line",
+ " try {",
+ " MATH_CONSTANTS.PI = 99;",
+ " } catch( ex ) {",
+ " console.log(ex);",
+ " }",
+ " return MATH_CONSTANTS.PI;",
+ "}",
+ "const PI = freezeObj();"
],
"tests": [
"getUserInput => assert(getUserInput('index').match(/const/g), 'message: Do not replace const
keyword.');",
- "getUserInput => assert(getUserInput('index').match(/const\\s+MATH_CONSTANTS/g), 'message: MATH_CONSTANTS
is declared with const
.');",
+ "getUserInput => assert(getUserInput('index').match(/const\\s+MATH_CONSTANTS/g), 'message: MATH_CONSTANTS
should be a constant variable (by using const
).');",
"getUserInput => assert(getUserInput('index').match(/const\\s+MATH_CONSTANTS\\s+=\\s+{\\s+PI:\\s+3.14\\s+};/g), 'message: Do not change original MATH_CONSTANTS
.');",
- "assert.deepEqual(MATH_CONSTANTS, {PI: 3.14}, 'message: MATH_CONSTANTS.PI
should be equal to 3.14
.');"
+ "assert(PI === 3.14, 'message: PI
equals 3.14
.');"
],
"type": "waypoint",
"releasedOn": "Aug 12, 2017",
@@ -218,18 +232,14 @@
"Rewrite the function assigned to the variable magic
which returns a new Date()
to use arrow function syntax. Also make sure nothing is defined using the keyword var
."
],
"challengeSeed": [
- "\"use strict\";",
- "// change code below this line",
"var magic = function() {",
+ " \"use strict\";",
" return new Date();",
- "}",
- "// change code above this line",
- "// test your code",
- "console.log(magic());"
+ "};"
],
"tests": [
"getUserInput => assert(!getUserInput('index').match(/var/g), 'message: User did replace var
keyword.');",
- "getUserInput => assert(getUserInput('index').match(/const\\s+magic/g), 'message: magic
is const
.');",
+ "getUserInput => assert(getUserInput('index').match(/const\\s+magic/g), 'message: magic
should be a constant variable (by using const
).');",
"assert(typeof magic === 'function', 'message: magic
is a function
.');",
"assert(magic().getDate() == new Date().getDate(), 'message: magic()
returns correct date.');",
"getUserInput => assert(!getUserInput('index').match(/function/g), 'message: function
keyword was not used.');"
@@ -250,18 +260,16 @@
"Rewrite the myConcat
function which appends contents of arr2
to arr1
so that the function uses arrow function syntax."
],
"challengeSeed": [
- "\"use strict\";",
- "// change code below this line",
"var myConcat = function(arr1, arr2) {",
+ " \"use strict\";",
" return arr1.concat(arr2);",
- "}",
- "// change code above this line",
+ "};",
"// test your code",
"console.log(myConcat([1, 2], [3, 4, 5]));"
],
"tests": [
"getUserInput => assert(!getUserInput('index').match(/var/g), 'message: User did replace var
keyword.');",
- "getUserInput => assert(getUserInput('index').match(/const\\s+myConcat/g), 'message: myConcat
is const
.');",
+ "getUserInput => assert(getUserInput('index').match(/const\\s+myConcat/g), 'message: myConcat
should be a constant variable (by using const
).');",
"assert(typeof myConcat === 'function', 'message: myConcat
should be a function');",
"assert(() => { const a = myConcat([1], [2]); return a[0] == 1 && a[1] == 2; }, 'message: myConcat()
returns the correct array
');",
"getUserInput => assert(!getUserInput('index').match(/function/g), 'message: function
keyword was not used.');"
@@ -286,18 +294,22 @@
"Use arrow function syntax to compute the square of only the positive integers (fractions are not integers) in the array realNumberArray
and store the new array in the variable squaredIntegers
."
],
"challengeSeed": [
- "\"use strict\";",
"const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34];",
- "// change code below this line",
- "var squaredIntegers = realNumberArray;",
- "// change code above this line",
+ "const squareList = (arr) => {",
+ " \"use strict\";",
+ " // change code below this line",
+ " const squaredIntegers = arr;",
+ " // change code above this line",
+ " return squaredIntegers;",
+ "};",
"// test your code",
+ "const squaredIntegers = squareList(realNumberArray);",
"console.log(squaredIntegers);"
],
"tests": [
"getUserInput => assert(!getUserInput('index').match(/var/g), 'message: User did replace var
keyword.');",
- "getUserInput => assert(getUserInput('index').match(/const\\s+squaredIntegers/g), 'message: squaredIntegers
is const
.');",
- "assert(Array.isArray(squaredIntegers), 'message: squaredIntegers
should be an array');",
+ "getUserInput => assert(getUserInput('index').match(/const\\s+squaredIntegers/g), 'message: squaredIntegers
should be a constant variable (by using const
).');",
+ "assert(Array.isArray(squaredIntegers), 'message: squaredIntegers
should be an array
');",
"assert(squaredIntegers[0] === 16 && squaredIntegers[1] === 1764 && squaredIntegers[2] === 36, 'message: squaredIntegers
should be [16, 1764, 36]
');",
"getUserInput => assert(!getUserInput('index').match(/function/g), 'message: function
keyword was not used.');",
"getUserInput => assert(!getUserInput('index').match(/(for)|(while)/g), 'message: loop should not be used');",
@@ -320,10 +332,12 @@
"Modify the function increment
by adding default parameters so that it will add 1 to number
if value
is not specified."
],
"challengeSeed": [
- "\"use strict\";",
- "function increment(number, value) {",
+ "const increment = (function() {",
+ " \"use strict\";",
+ " return function increment(number, value) {",
" return number + value;",
- "}",
+ " };",
+ "})();",
"console.log(increment(5, 2)); // returns 7",
"console.log(increment(5)); // returns NaN"
],
@@ -349,11 +363,13 @@
"Modify the function sum
so that is uses the rest operator and it works in the same way with any number of parameters."
],
"challengeSeed": [
- "\"use strict\";",
- "function sum(x, y, z) {",
+ "const sum = (function() {",
+ " \"use strict\";",
+ " return function sum(x, y, z) {",
" const array = [ x, y, z ];",
" return array.reduce((a, b) => a + b, 0);",
- "}",
+ " };",
+ "})();",
"console.log(sum(1, 2, 3)); // 6"
],
"tests": [
@@ -385,9 +401,12 @@
"Copy all contents of arr1
into another array arr2
using the spread operator."
],
"challengeSeed": [
- "\"use strict\";",
- "const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];",
- "const arr2 = [] // change this line",
+ "const arr1 = ['JAN', 'FEB', 'MAR', 'APR', 'MAY'];",
+ "let arr2;",
+ "(function() {",
+ " \"use strict\";",
+ " arr2 = []; // change this line",
+ "})();",
"console.log(arr2);"
],
"tests": [
@@ -414,22 +433,26 @@
"const { x : a, y : b, z : c } = voxel // a = 3.6, b = 7.4, c = 6.54", "You may read it as \"get the field
x
and copy the value into a
,\" and so on.",
"greeting
, and assign the length to len
"
+ "Use destructuring to obtain the length of the input string str
, and assign the length to len
in line."
],
"challengeSeed": [
- "\"use strict\";",
- "const greeting = 'itadakimasu';",
+ "function getLength(str) {",
+ " \"use strict\";",
"",
- "// change code below this line",
- "const length = 0; // change this",
- "// change code above this line",
+ " // change code below this line",
+ " const length = 0; // change this",
+ " // change code above this line",
"",
- "console.log(length); // should be using destructuring"
+ " return len; // you must assign length to len in line",
+ "",
+ "}",
+ "",
+ "console.log(getLength('FreeCodeCamp'));"
],
"tests": [
- "assert(typeof len === 'number', 'message: variable len
exists and is a number.');",
- "assert(len === 11, 'message: len
equals 11
');",
- "getUserInput => assert(getUserInput('index').match(/\\{\\s*length\\s*:\\s*len\\s*}\\s*=\\s*greeting/g),'message: destructuring was used');"
+ "assert(typeof getLength('') === 'number', 'message: the function getLength()
returns a number.');",
+ "assert(getLength(\"FreeCodeCamp\") === 12, 'message: getLength(\"FreeCodeCamp\")
should be 12
');",
+ "getUserInput => assert(getUserInput('index').match(/\\{\\s*length\\s*:\\s*len\\s*}\\s*=\\s*str/g),'message: destructuring with reassignment was used');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -448,18 +471,23 @@
"Use destructuring assignment to obtain max
of forecast.tomorrow
and assign it to maxOfTomorrow
."
],
"challengeSeed": [
- "\"use strict\";",
- "const forecast = {",
+ "const LOCAL_FORECAST = {",
" today: { min: 72, max: 83 },",
" tomorrow: { min: 73.3, max: 84.6 }",
"};",
- "// change code below this line",
- "const maxOfTomorrow = undefined; // change this line",
- "// change code above this line",
- "console.log(maxOfTomorrow); // should be 84.6"
+ "",
+ "function getMaxOfTmrw(forecast) {",
+ " \"use strict\";",
+ " // change code below this line",
+ " const maxOfTomorrow = undefined; // change this line",
+ " // change code above this line",
+ " return maxOfTomorrow;",
+ "}",
+ "",
+ "console.log(getMaxOfTmrw(LOCAL_FORECAST)); // should be 84.6"
],
"tests": [
- "assert(maxOfTomorrow === 84.6, 'message: maxOfTomorrow
equals 84.6
');",
+ "assert(getMaxOfTmrw(LOCAL_FORECAST) === 84.6, 'message: maxOfTomorrow
equals 84.6
');",
"getUserInput => assert(getUserInput('index').match(/\\{\\s*tomorrow\\s*:\\s*\\{\\s*max\\s*:\\s*maxOfTomorrow\\s*\\}\\s*\\}\\s*=\\s*forecast/g),'message: nested destructuring was used');"
],
"type": "waypoint",
@@ -482,11 +510,13 @@
"Use destructuring assignment to swap the values of a
and b
so that a
receives the value stored in b
, and b
receives the value stored in a
."
],
"challengeSeed": [
- "\"use strict\";",
"let a = 8, b = 6;",
- "// change code below this line",
- "",
- "// change code above this line",
+ "(() => {",
+ " \"use strict\";",
+ " // change code below this line",
+ " ",
+ " // change code above this line",
+ "})();",
"console.log(a); // should be 6",
"console.log(b); // should be 8"
],
@@ -513,18 +543,22 @@
"Use destructuring assignment with the rest operator to perform an effective Array.prototype.slice()
so that arr
is a sub-array of the original array source
with the first two elements ommitted."
],
"challengeSeed": [
- "\"use strict\";",
"const source = [1,2,3,4,5,6,7,8,9,10];",
- "// change code below this line",
- "const arr = source; // change this",
- "// change code below this line",
+ "function removeFirstTwo(list) {",
+ " \"use strict\";",
+ " // change code below this line",
+ " arr = list; // change this",
+ " // change code below this line",
+ " return arr;",
+ "}",
+ "const arr = removeFirstTwo(source);",
"console.log(arr); // should be [3,4,5,6,7,8,9,10]",
"console.log(source); // should be [1,2,3,4,5,6,7,8,9,10];"
],
"tests": [
- "assert(arr.every((v, i) => v === i + 3),'message: arr
is [3,4,5,6,7,8,9,10]
');",
+ "assert(arr.every((v, i) => v === i + 3),'message: arr
should be [3,4,5,6,7,8,9,10]
');",
"getUserInput => assert(getUserInput('index').match(/\\[\\s*\\w\\s*,\\s*\\w\\s*,\\s*...arr\\s*\\]/g),'message: destructuring was used.');",
- "getUserInput => assert(!getUserInput('index').match(/Array.slice\\(\\)/g), 'message: Array.slice()
was not used.');"
+ "getUserInput => assert(!getUserInput('index').match(/Array.slice/g), 'message: Array.slice()
was not used.');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -546,7 +580,6 @@
"Use destructuring assignment within the argument to the function half
to send only max
and min
inside the function."
],
"challengeSeed": [
- "\"use strict\";",
"const stats = {",
" max: 56.78,",
" standard_deviation: 4.34,",
@@ -555,16 +588,24 @@
" min: -0.75,",
" average: 35.85",
"};",
- "// change code below this line",
- "const half = (stats) => ((stats.max + stats.min) / 2.0); // use function argument destructurung",
- "// change code above this line",
+ "const half = (function() {",
+ " \"use strict\"; // do not change this line",
+ "",
+ " // change code below this line",
+ " return function half(stats) {",
+ " // use function argument destructuring",
+ " return (stats.max + stats.min) / 2.0;",
+ " };",
+ " // change code above this line",
+ "",
+ "})();",
"console.log(stats); // should be object",
"console.log(half(stats)); // should be 28.015"
],
"tests": [
- "assert(typeof stats === 'object', 'message: stats
is an object
.');",
- "assert(half(stats) === 28.015, 'message: half(stats)
is 28.015
');",
- "getUserInput => assert(getUserInput('index').match(/\\(\\s*\\{\\s*\\w+\\s*,\\s*\\w+\\s*\\}\\s*\\)/g), 'message: destructuring was used.');"
+ "assert(typeof stats === 'object', 'message: stats
should be an object
.');",
+ "assert(half(stats) === 28.015, 'message: half(stats)
should be 28.015
');",
+ "getUserInput => assert(getUserInput('index').match(/\\(\\s*\\{\\s*\\w+\\s*,\\s*\\w+\\s*\\}\\s*\\)/g), 'message: Destructuring was used.');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -586,27 +627,32 @@
"Use template literal syntax with backticks to display each entry of the result
object's failure
array. Each entry should be wrapped inside an li
element with the class attribute text-warning
, and listed within the resultDisplayArray
."
],
"challengeSeed": [
- "\"use strict\";",
"const result = {",
" success: [\"max-length\", \"no-amd\", \"prefer-arrow-functions\"],",
" failure: [\"no-var\", \"var-on-top\", \"linebreak\"],",
" skipped: [\"id-blacklist\", \"no-dup-keys\"]",
"};",
- "// change code below this line",
- "const resultDisplayArray = null;",
- "// change code above this line",
- "console.log(resultDisplayArray);",
+ "function makeList(arr) {",
+ " \"use strict\";",
+ "",
+ " // change code below this line",
+ " const resultDisplayArray = null;",
+ " // change code above this line",
+ "",
+ " return resultDisplayArray;",
+ "}",
"/**",
- " * should look like this",
- " * resultDisplayArray
is a list containing result failure
messages.');",
- "assert(resultDisplayArray.every((v, i) => v === `resultDisplayArray
is the desired output.');",
- "getUserInput => assert(getUserInput('index').match(/\\`resultDisplayArray
is a list containing result failure
messages.');",
+ "assert(makeList(result.failure).every((v, i) => v === `resultDisplayArray
is the desired output.');",
+ "getUserInput => assert(getUserInput('index').match(/\\`Person
object."
],
"challengeSeed": [
- "\"use strict\";",
- "// change code below this line",
"const createPerson = (name, age, gender) => {",
+ " \"use strict\";",
+ " // change code below this line",
" return {",
" name: name,",
" age: age,",
" gender: gender",
" };",
+ " // change code above this line",
"};",
- "// change code above this line",
"console.log(createPerson(\"Zodiac Hasbro\", 56, \"male\")); // returns a proper object"
],
"tests": [
@@ -661,11 +707,12 @@
"Refactor the function setGear
inside the object bicycle
to use the shorthand syntax described above."
],
"challengeSeed": [
- "\"use strict\";",
+
"// change code below this line",
"const bicycle = {",
" gear: 2,",
" setGear: function(newGear) {",
+ " \"use strict\";",
" this.gear = newGear;",
" }",
"};",
@@ -698,17 +745,21 @@
"The Vegetable
lets you create a vegetable object, with a property name
, to be passed to constructor."
],
"challengeSeed": [
- "\"use strict\";",
- "/* Alter code below this line */",
- "const Vegetable = undefined;",
- "/* Alter code above this line */",
+ "function makeClass() {",
+ " \"use strict\";",
+ " /* Alter code below this line */",
+ "",
+ " /* Alter code above this line */",
+ " return Vegetable;",
+ "}",
+ "const Vegetable = makeClass();",
"const carrot = new Vegetable('carrot');",
"console.log(carrot.name); // => should be 'carrot'"
],
"tests": [
- "assert(typeof Vegetable === 'function' && typeof Vegetable.constructor === 'function', 'message: Vegetable
is a class
');",
+ "assert(typeof Vegetable === 'function' && typeof Vegetable.constructor === 'function', 'message: Vegetable
should be a class
with a defined constructor
method.');",
"getUserInput => assert(getUserInput('index').match(/class/g),'message: class
keyword was used.');",
- "assert(() => {const a = new Vegetable(\"apple\"); return typeof a === 'object';},'message: Instances of Vegetable
can be instantiated.');"
+ "assert(() => {const a = new Vegetable(\"apple\"); return typeof a === 'object';},'message: Vegetable
can be instantiated.');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",
@@ -736,19 +787,23 @@
"In other words, you are abstracting implementation details from the consumer."
],
"challengeSeed": [
- "\"use strict\";",
- "/* Alter code below this line */",
- "const Thermostat = undefined;",
- "/* Alter code above this line */",
+ "function makeClass() {",
+ " \"use strict\";",
+ " /* Alter code below this line */",
+ "",
+ " /* Alter code above this line */",
+ " return Thermostat;",
+ "}",
+ "const Thermostat = makeClass();",
"const thermos = new Thermostat(76); // setting in Farenheit scale",
"let temp = thermos.temperature; // 24.44 in C",
"thermos.temperature = 26;",
"temp = thermos.temperature; // 26 in C"
],
"tests": [
- "assert(typeof Thermostat === 'function' && typeof Thermostat.constructor === 'function','message: Thermostat
is a class
');",
+ "assert(typeof Thermostat === 'function' && typeof Thermostat.constructor === 'function','message: Thermostat
should be a class
with a defined constructor
method.');",
"getUserInput => assert(getUserInput('index').match(/class/g),'message: class
keyword was used.');",
- "assert(() => {const t = new Thermostat(32); return typeof t === 'object' && t.temperature === 0;}, 'message: Instances of Vegetable
can be instantiated.');"
+ "assert(() => {const t = new Thermostat(32); return typeof t === 'object' && t.temperature === 0;}, 'message: Thermostat
can be instantiated.');"
],
"type": "waypoint",
"releasedOn": "Feb 17, 2017",