diff --git a/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json b/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json index cda04ccd00d..c41f03a61cb 100644 --- a/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json +++ b/seed/challenges/02-javascript-algorithms-and-data-structures/es6.json @@ -168,6 +168,39 @@ "challengeType": 1, "translations": {} }, + { + "id": "598f48a36c8c40764b4e52b3", + "title": "Prevent Object Mutation", + "description": [ + "As seen in previous challenge, const declration alone doesn't really protect your data from mutation. To ensure your data doesn't change, JavaScript provides a function Object.freeze to prevent data mutation.", + "Once the object is freezed, you can no longer add/update/delete properties from it. Any attempt at changing the object will be rejected without any error.", + "
\nlet obj = {\n name:\"FreeCodeCamp\"\n review:\"Awesome\"\n};\nObject.freeze(obj);\nobj.review = \"bad\"; //will be ignored. Mutation not allowed\nobj.newProp = \"Test\"; // will be ignored. Mutation not allowed\nconsole.log(obj); \n// { name: \"FreeCodeCamp\", review:\"Awesome\"}\n
", + "
", + "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": [ + "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" + ], + "tests": [ + "// Do not replace const keyword.", + "// MATH_CONSTANTS is declared with const.", + "// Do not change original MATH_CONSTANTS", + "assert.deepEqual(MATH_CONSTANTS, {PI: 3.14}, 'message: MATH_CONSTANTS.PI should be equal to 3.14.');" + ], + "type": "waypoint", + "releasedOn": "Aug 12, 2017", + "challengeType": 1, + "translations": {} + }, { "id": "587d7b87367417b2b2512b43", "title": "Use Arrow Functions to Write Concise Anonymous Functions",