diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json index ed7b654e9e..3625ddb628 100644 --- a/challenges/01-front-end-development-certification/basic-javascript.json +++ b/challenges/01-front-end-development-certification/basic-javascript.json @@ -2118,27 +2118,52 @@ }, { "id": "56533eb9ac21ba0edf2244c6", - "title": "Checkpoint: Functions", + "title": "Stand in Line", "description": [ - "Note: Function Length tips - 10-20 lines, etc", - "\"Queue\"", - "myFunction(arr, item)", - "", - "Push item on end of array", - "pop item off front", - "" + "In Computer Science a queue is an abastract datatype where items are kept in order. New items can be added to the back of the queue and old items are taken off the front of the queue.", + "Write a function queue which takes an array and an item as arguments. Add the item onto the end of the array, then remove and return the item at the front of the queue." ], "releasedOn": "11/27/2015", "tests": [ - "assert(1===1, 'message: message here');" + "assert(queue([],1) === 1, 'message: queue([], 1) should return 1');", + "assert(queue([2],1) === 2, 'message: queue([2], 1) should return 2');", + "queue(myArr, 10); assert(myArr[4] === 10, 'message: After queue(myArr, 10), myArr[4] should be 10');" + ], + "head": [ + "var logOutput = [];", + "var oldLog = console.log;", + "function capture() {", + " console.log = function (message) {", + " logOutput.push(message);", + " oldLog.apply(console, arguments);", + " };", + "}", + "", + "function uncapture() {", + " console.log = oldLog;", + "}", + "", + "capture();" ], "challengeSeed": [ + "// Setup", + "var myArr = [1,2,3,4,5];", "", + "function queue(arr, item) {", + " // Your code here", + " ", + " return item; // Change this line", + "}", "", - "" + "// Display Code", + "console.log(\"Before: \" + JSON.stringify(myArr));", + "console.log(queue(myArr, 6)); // Modify this line to test", + "console.log(\"After: \" + JSON.stringify(myArr));" ], "tail": [ - "" + "uncapture();", + "myArr = [1,2,3,4,5];", + "(function() { return logOutput.join(\"\\n\");})();" ], "solutions": [ "var arr = [ 1,2,3,4,5];", @@ -2148,8 +2173,8 @@ " return myArr.shift();", "}" ], - "type": "waypoint", - "challengeType": "1", + "type": "bonfire", + "challengeType": "5", "nameCn": "", "nameFr": "", "nameRu": "", @@ -3231,16 +3256,31 @@ "title": "Returning Boolean Values from Functions", "description": [ "You may recall from Comparison with the Equality Operator that all comparison operators return a boolean true or false value.", - "A common anti-pattern is to use an if/else statement to do a comparison and then return true/false." + "A common anti-pattern is to use an if/else statement to do a comparison and then return true/false:", + "
function isEqual(a,b) {
if(a === b) {
return true;
} else {
return false;
}
}
", + "Since === returns true or false, we can simply return the result of the comparion:", + "
function isEqual(a,b) {
return a === b;
}
", + "

Instructions

", + "Fix the function isLess to remove the if/else statements." ], "releasedOn": "11/27/2015", "tests": [ - "assert(1===1, 'message: message here');" + "assert(isLess(10,15) === true, 'message: isLess(10,15) should return true');", + "assert(isLess(15, 10) === false, 'message: isLess(15,10) should return true');", + "assert(!/if|else/g.test(editor.getValue()), 'message: You should not use any if or else statements');" ], "challengeSeed": [ + "function isLess(a, b) {", + " // Fix this code", + " if(a < b) {", + " return true;", + " } else {", + " return false;", + " }", + "}", "", - "", - "" + "// Change these values to test", + "isLess(10, 15);" ], "tail": [ "" @@ -3260,7 +3300,7 @@ "id": "56533eb9ac21ba0edf2244c4", "title": "Return Early Pattern for Functions", "description": [ - "Explain how to use return early for functions" + "When a return statement is reached, the execution of the current function stops at that point. " ], "releasedOn": "11/27/2015", "tests": [ @@ -3829,6 +3869,58 @@ "nameEs": "", "namePt": "" }, + { + "id": "567af2437cbaa8c51670a16c", + "title": "Testing Objects for Properties", + "description": [ + "Sometimes it is useful to check of the property of a given object exists or not. We can use the .hasOwnProperty([propname]) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not.", + "Example:", + "
var myObj = {
top: \"hat\",
bottom: \"pants\"
};
myObj.hasOwnProperty(\"hat\"); // true
myObj.hasOwnProperty(\"middle\"); // false
", + "

Instructions

", + " Modify function checkObj to test myObj for checkProp. If the property is found, return that property's value. If not return \"Not Found\"." + ], + "tests": [ + "assert(checkObj(\"gift\") === \"pony\", 'message: checkObj(\"gift\") should return \"pony\".');", + "assert(checkObj(\"pet\") === \"kitten\", 'message: checkObj(\"gift\") should return \"kitten\".');", + "assert(checkObj(\"house\") === \"Not Found\", 'message: checkObj(\"house\") should return \"Not Found\".');" + ], + "challengeSeed": [ + "// Setup", + "var myObj = {", + " gift: \"pony\",", + " pet: \"kitten\",", + " bed: \"sleigh\"", + "};", + "", + "function checkObj(checkProp) {", + " // Your Code Here", + "", + " return \"Change Me!\";", + "}", + "", + "// Test your code by modifying these values", + "checkObj(\"gift\");" + ], + "tail": [ + "" + ], + "solutions": [ + "var myObj = {", + " gift: \"pony\",", + " pet: \"kitten\",", + " bed: \"sleigh\"", + "};", + "function checkObj(checkProp) {", + " if(myObj.hasOwnProperty(checkProp)) {", + " return myObj[checkProp];", + " } else {", + " return \"Not Found\";", + " }", + "}" + ], + "type": "waypoint", + "challengeType": "1" + }, { "id": "56533eb9ac21ba0edf2244cb", "title": "Introducing JavaScript Object Notation (JSON)", @@ -4022,9 +4114,9 @@ }, { "id": "56533eb9ac21ba0edf2244ce", - "title": "Arbitrary Nesting in JSON", + "title": "Modifying JSON Values", "description": [ - "Retrieve a value from an arbitary JSON" + "Modify the contents of a JSON object" ], "releasedOn": "11/27/2015", "tests": [ @@ -4035,6 +4127,9 @@ "", "" ], + "tail": [ + "" + ], "solutions": [ "" ], @@ -4328,24 +4423,35 @@ }, { "id": "56533eb9ac21ba0edf2244e2", - "title": "Checkpoint: Conditionals and Loops", + "title": "Caesar's Cipher", "description": [ - "" + "One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount. ", + "A common modern use is a ROT13 cipher, where the values of the letters are shifted by 13 places. Thus A = N, B = O and so on.", + "Write a function which takes a ROT13 encoded array of characters as input and returns a plain text encoded array. All letters will be uppercase. Do not transform any non-alphabetic character (IE: spaces, punctiation)." ], "releasedOn": "11/27/2015", "tests": [ - "assert(1===1, 'message: message here');" + "assert( rot13([ 'S', 'E', 'R', 'R', ' ', 'P', 'B', 'Q', 'R', ' ', 'P', 'N', 'Z', 'C' ]).join(\"\") === \"FREE CODE CAMP\", 'message: rot13([ 'S', 'E', 'R', 'R', ' ', 'P', 'B', 'Q', 'R', ' ', 'P', 'N', 'Z', 'C' ]) should decode to [ 'F', 'R', 'E', 'E', ' ', 'C', 'O', 'D', 'E', ' ', 'C', 'A', 'M', 'P' ]');", + "assert(1===1, 'message: blah');" ], "challengeSeed": [ + "function rot13(codeArr) {", + " // Your Code Here", "", + " return []; // Change this Line", + "}", "", + "// Change the inputs below to test", + "rot13([ 'S', 'E', 'R', 'R', ' ', 'P', 'B', 'Q', 'R', ' ', 'P', 'N', 'Z', 'C' ]);" + ], + "tail": [ "" ], "solutions": [ "" ], - "type": "waypoint", - "challengeType": "1", + "type": "bonfire", + "challengeType": "5", "nameCn": "", "nameFr": "", "nameRu": "",