diff --git a/challenges/01-front-end-development-certification/basic-javascript.json b/challenges/01-front-end-development-certification/basic-javascript.json index 95c59ccac22..2763f16f4e6 100644 --- a/challenges/01-front-end-development-certification/basic-javascript.json +++ b/challenges/01-front-end-development-certification/basic-javascript.json @@ -1914,8 +1914,12 @@ "assert(1===1, 'message: message here');" ], "challengeSeed": [ + "function myFunction() {", + " ", + " console.log(myVar);", + "}", "", - "", + "console.log(myVar);", "" ], "tail": [ @@ -4127,21 +4131,44 @@ "description": [ "If you have a multi-dimensional array, you can use the same logic as the prior waypoint to loop through both the array and any sub-arrays. Here is an example:", "
var arr = [", - "This outputs each sub-element in
[1,2], [3,4], [5,6]
];
for (var i=0; i < arr.length; i++) {
for (var j=0; k < arr[i].length; j++) {
console.log(arr[i][j]);
}
}
arr one at a time. Note that for the inner loop we are checking the .length of arr[i], since arr[i] is itself an array."
+ "This outputs each sub-element in arr one at a time. Note that for the inner loop we are checking the .length of arr[i], since arr[i] is itself an array.",
+ "multiplyAll will be passed a multi-dimensional array, arr. Loop through both levels of arr and multiply product by each one."
],
"releasedOn": "11/27/2015",
"tests": [
- "assert(1===1, 'message: message here');"
+ "assert(multiplyAll([[1],[2],[3]]) === 6, 'message: multiplyAll([[1],[2],[3]]); should return 6');",
+ "assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, 'message: multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040');",
+ "assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, 'message: multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]);) should return 54');"
],
"challengeSeed": [
+ "function multiplyAll(arr) {",
+ " var product = 1;",
+ " // Only change code below this line",
"",
+ " // Only change code above this line",
+ " return product;",
+ "}",
"",
+ "// Modify values below to test your code",
+ "multiplyAll([[1,2],[3,4],[5,6,7]]);",
""
],
"tail": [
""
],
"solutions": [
+ "function multiplyAll(arr) {",
+ " var product = 1;",
+ " for (var i = 0; i < arr.length; i++) {",
+ " for (var j = 0; j < arr[i].length; j++) {",
+ " product *= arr[i][j];",
+ " }",
+ " }",
+ " return product;",
+ "}",
+ "",
+ "multiplyAll([[1,2],[3,4],[5,6,7]]);",
+ "",
""
],
"type": "waypoint",
@@ -4158,31 +4185,25 @@
"description": [
"You can run the same code multiple times by using a loop.",
"Another type of JavaScript loop is called a \"while loop\", because it runs \"while\" something is true and stops once that something is no longer true.",
- "var ourArray = [];",
- "var i = 0;",
- "while(i < 5) {",
- " ourArray.push(i);",
- " i++;",
- "}",
+ "var ourArray = [];", "Let's try getting a while loop to work by pushing values to an array.", - "Push the numbers 0 through 4 to
var i = 0;
while(i < 5) {
ourArray.push(i);
i++;
}
myArray using a while loop."
+ "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].');"
],
"challengeSeed": [
+ "// Setup",
"var myArray = [];",
"",
"// Only change code below this line.",
"",
- "",
- "",
- "// Only change code above this line.",
- "",
- "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}",
""
],
+ "tail": [
+ "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}"
+ ],
"type": "waypoint",
"challengeType": "1"
},