From 2843bd804a9d31a41d2980ed33c87e0888828570 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Tue, 15 Sep 2015 00:52:15 -0700 Subject: [PATCH 001/118] add an assertion to ensure well-formed img elements in waypoint-make-images-mobile-responsive challenge, closes #1021 --- seed/challenges/bootstrap.json | 1 + 1 file changed, 1 insertion(+) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..35b7a02321 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -97,6 +97,7 @@ ], "tests": [ "assert($(\"img\").length > 1, 'You should have a total of two images.')", + "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" ], From 165cb41080443f0f061185c6fb5a87f22c16bcd1 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Wed, 16 Sep 2015 18:04:37 -0700 Subject: [PATCH 002/118] fix count img elements assertion in waypoint-make-images-mobile-responsive challenge to be strict --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index 35b7a02321..f953d8e58a 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -96,7 +96,7 @@ "Fortunately, with Bootstrap, all we need to do is add the img-responsive class to your image. Do this, and the image should perfectly fit the width of your page." ], "tests": [ - "assert($(\"img\").length > 1, 'You should have a total of two images.')", + "assert($(\"img\").length === 2, 'You should have a total of two images.')", "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" From be373787831a45bfce00b92ab70e35dc4f5cd676 Mon Sep 17 00:00:00 2001 From: Pavel Tsurbeleu Date: Wed, 16 Sep 2015 18:10:16 -0700 Subject: [PATCH 003/118] fix wording of src attribute assertion's message to be consistent with other messages in waypoint-make-images-mobile-responsive challenge --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index f953d8e58a..bfc812b897 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -99,7 +99,7 @@ "assert($(\"img\").length === 2, 'You should have a total of two images.')", "assert(editor.match(//g).length === 2 && editor.match(/img element has a closing angle bracket.')", "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", - "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" + "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Your new image should have a src attribute of http://bit.ly/fcc-running-cats.')" ], "challengeSeed": [ "", From 12ef390288288670374a2219dbaf338a85165b5d Mon Sep 17 00:00:00 2001 From: Arsen Melikyan Date: Sun, 20 Sep 2015 00:42:01 +0400 Subject: [PATCH 004/118] new test checks if all elements are nested in container-fluid --- seed/challenges/bootstrap.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..2e83b66f8d 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -14,8 +14,9 @@ "To get started, we should nest all of our HTML in a div element with the class container-fluid." ], "tests": [ - "assert($(\"div\").hasClass(\"container-fluid\"), 'Your div element should have the class container-fluid')", - "assert(editor.match(/<\\/div>/g) && editor.match(/
/g).length === editor.match(/
div elements has a closing tag.')" + "assert($(\"div\").hasClass(\"container-fluid\"), 'Your div element should have the class container-fluid.')", + "assert(editor.match(/<\\/div>/g) && editor.match(/
/g).length === editor.match(/
div elements has a closing tag.')", + "assert($(\".container-fluid\").children().length >= 8, 'Make sure you have nested all HTML elements in .container-fluid.')" ], "challengeSeed": [ "", From 0a455fcd9231d2a13374380be6722d71a1f53d6b Mon Sep 17 00:00:00 2001 From: Aniruddh Agarwal Date: Fri, 18 Sep 2015 15:31:25 +0800 Subject: [PATCH 005/118] Fixes basic bonfire's permissive test --- seed/challenges/basic-bonfires.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index cbcdbd1b83..a5df1ea9ec 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -313,7 +313,7 @@ "tests": [ "assert(end(\"Bastian\", \"n\") === true, '\"Bastian\", \"n\" should return true.');", "assert(end(\"Connor\", \"n\") === false, '\"Connor\", \"n\" should return false.');", - "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, '\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") should return false.');", + "assert(end(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") === false, '\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") should return false.');", "assert(end(\"He has to give me a new name\", \"name\") === true, '\"He has to give me a new name\", \"name\" should return true.');", "assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, '\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\" should return false.');" ], From 182960af04cd8b65ff47aafe735a3c27b1120cfc Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 20 Sep 2015 15:52:54 -0400 Subject: [PATCH 006/118] Fix tests on Waypoint Mobile Responsive Images --- seed/challenges/bootstrap.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index fb4f864474..d56663a44d 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -97,8 +97,8 @@ ], "tests": [ "assert($(\"img\").length > 1, 'You should have a total of two images.')", - "assert($(\"img\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')", - "assert(new RegExp(\"http://bit.ly/fcc-running-cats\", \"gi\").test($(\"img.img-responsive\").attr(\"src\")), 'Add a second image with the src of http://bit.ly/fcc-running-cats.')" + "assert($(\"img:eq(1)\").attr(\"src\") === \"http://bit.ly/fcc-running-cats\", 'Your new image should have an src of http://bit.ly/fcc-running-cats.')", + "assert($(\"img:eq(1)\").hasClass(\"img-responsive\"), 'Your new image should have the class img-responsive.')" ], "challengeSeed": [ "", From e0df3171f42d67c5648f1274cb212ec6d8cad350 Mon Sep 17 00:00:00 2001 From: Rich Churcher Date: Mon, 21 Sep 2015 08:34:22 +1200 Subject: [PATCH 007/118] Make plain that the array is not already sorted. --- seed/challenges/basic-bonfires.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index cbcdbd1b83..e537eda1e6 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -613,8 +613,9 @@ "title": "Where do I belong", "difficulty": "1.61", "description": [ - "Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).", - "For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index).", + "Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.", + "For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).", + "Likewise, where([20,3,5], 19) should return 2 because it is less than 20 (index 2) and greater than 5 (index 1).", "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "challengeSeed": [ From d9d558a8a9c2b03f01882d60cc646c3d1b57e61d Mon Sep 17 00:00:00 2001 From: ahstro Date: Mon, 21 Sep 2015 23:10:13 +0200 Subject: [PATCH 008/118] Slot Machine false positives The 'Add your JavaScript Slot Machine Slots' waypoint would throw false positives if all slot numbers were the same, effectively allowing the campers to pass the test without having written any code. --- seed/challenges/basic-javascript.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index e3542ee41d..53cc76410b 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1302,7 +1302,7 @@ "}" ], "tests":[ - "assert((function(){var data = runSlots();if(data === null){return true}else{if(data[0] === data[1] && data[1] === data[2]){return true;}else{return false;}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.')" + "assert((function(){var data = runSlots();return data === null || data.toString().length === 1;})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null.')" ], "challengeSeed":[ "fccss", @@ -1485,9 +1485,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $(\".logger\").html(slotOne);", @@ -1655,9 +1656,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $('.logger').html(slotOne);", From e2459fa869f3c05cf659b2cb41d0f7bdd1aadec6 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 28 Sep 2015 23:24:42 +0100 Subject: [PATCH 009/118] Foundation fo AJAX stuff is done. Going to move on to process fetched data and creating a UI generating function for each individual object --- seed/challenges/json-apis-and-ajax.json | 116 ++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 seed/challenges/json-apis-and-ajax.json diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json new file mode 100644 index 0000000000..8ece73714b --- /dev/null +++ b/seed/challenges/json-apis-and-ajax.json @@ -0,0 +1,116 @@ +{ + "name": "JSON APIs and Ajax", + "order": 0.0065, + "challenges": [ + { + "id": "bad87fed1348bd9aeca08826", + "title": "Trigger on click Events with jQuery", + "difficulty": 3.19, + "description": [ + "With jQuery we are able to get data from APIs via Ajax", + "This data normally comes in the form of JSON", + "Let's get the Get Message button to set the text of a div", + "We will later use this to display the result of out API request", + "$(\"#getMessage\").on(\"click\", function(){", + "  $(\".message\").html(\"Here is the message\");", + "});" + ], + "tests": [ + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button')", + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", + "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " });", + "fcces", + "", + "", + "", + "
", + "
", + "

Cat Photo Finder

", + "
", + "
", + "
", + "
", + " The message will go here", + "
", + "
", + "
", + "
", + "
", + " ", + "
", + "
", + "
" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bad87fee1348bd9aebc08826", + "title": "Get Data from an URL Using jQuery", + "dashedName": "waypoint-get-data-from-a-url-using-jquery", + "difficulty": 3.21, + "description": [ + "", + "We are now going to request data from an external source. (a file on FCC for the purposes of this exercise) The request will load in the data an run the code in the function we provide the data to which is known as the callback.", + "$(\"#getMessage\").on(\"click\", function() {", + "  $.getJSON(\"/json/cats.json?callback=?\", function( json ) {", + "    //Code to run when request is complete", + "    $(\".message\").html(JSON.stringify(json))", + "  });", + "});", + "Let's make it so that the data sent from the request is appended to the .message div", + "" + ], + "tests": [ + "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\\?\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", + "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function(){", + " $(\".message\").html(\"Make the result of the getJSON request appear here\")", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
", + "
", + "

Cat Photo Finder

", + "
", + "
", + "
", + "
", + " The message will go here", + "
", + "
", + "
", + "
", + "
", + " ", + "
", + "
", + "
" + ], + "challengeType": 0, + "type": "waypoint" + } + ] +} From 963856b278f98948feef9a0d8c1af95036aca934 Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Tue, 29 Sep 2015 19:00:50 +0800 Subject: [PATCH 010/118] Additional tweaks to doc to get it working --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b0c87d631..90e6cd40cd 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ touch .env npm install -g gulp ``` -Edit your `.env` file with the following API keys accordingly (if you only use email login, only the `MONGOHQ_URL`, `SESSION_SECRET`, `MANDRILL_USER` and `MANDRILL_PASSWORD` fields are necessary. Keep in mind if you want to use more services you'll have to get your own API keys for those services. +Edit your `.env` file with the following API keys accordingly. If you only use email login, only the `MONGOHQ_URL`, `SESSION_SECRET`, `MANDRILL_USER` and `MANDRILL_PASSWORD` fields are necessary. Keep in mind if you want to use more services you'll have to get your own API keys for those services. If you only use a subset or no OAuth2 authentication methods, you have to remove them from ```server/passport-providers.js``` otherwise the server will complain of missing clientID at launch. ``` MONGOHQ_URL='mongodb://localhost:27017/freecodecamp' @@ -122,6 +122,8 @@ node seed/ gulp ``` +Note that you may need to run gulp before ```node seed/``` one time to create ```server/rev-manifest.json``` (on which the seeding scripts also depend). + License ------- From 90230ec907db1536af7386ac7ff2ffd0746f0db1 Mon Sep 17 00:00:00 2001 From: natac13 Date: Wed, 30 Sep 2015 05:13:13 -0400 Subject: [PATCH 011/118] fix test so it does not match code not in the answer --- seed/challenges/basic-javascript.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 13c28c2021..5c15e74bf5 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1491,7 +1491,7 @@ " }", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", - " $(\".logger\").html(slotOne);", + " $(\".logger\").text(slotOne);", " $(\".logger\").append(\" \" + slotTwo);", " $(\".logger\").append(\" \" + slotThree);", " }", From 2d6c91b51326c4b6c0fdb00f54604afa868485f5 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Wed, 30 Sep 2015 23:01:56 +0100 Subject: [PATCH 012/118] Three complete. More to come --- seed/challenges/json-apis-and-ajax.json | 87 ++- .../json-apis-and-ajax.json | 535 ------------------ 2 files changed, 80 insertions(+), 542 deletions(-) delete mode 100644 seed/under-construction/json-apis-and-ajax.json diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 8ece73714b..9f96865672 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -3,7 +3,7 @@ "order": 0.0065, "challenges": [ { - "id": "bad87fed1348bd9aeca08826", + "id": "bb000000000000000000000", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ @@ -53,15 +53,14 @@ "type": "waypoint" }, { - "id": "bad87fee1348bd9aebc08826", - "title": "Get Data from an URL Using jQuery", - "dashedName": "waypoint-get-data-from-a-url-using-jquery", - "difficulty": 3.21, + "id": "bb000000000000000000001", + "title": "Creating HTML from Data from an AJAX request Using jQuery", + "difficulty": 3.20, "description": [ "", "We are now going to request data from an external source. (a file on FCC for the purposes of this exercise) The request will load in the data an run the code in the function we provide the data to which is known as the callback.", "$(\"#getMessage\").on(\"click\", function() {", - "  $.getJSON(\"/json/cats.json?callback=?\", function( json ) {", + "  $.getJSON(\"/json/cats.json?callback=\", function( json ) {", "    //Code to run when request is complete", "    $(\".message\").html(JSON.stringify(json))", "  });", @@ -73,7 +72,7 @@ "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", - "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\\?\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" ], "challengeSeed": [ @@ -111,6 +110,80 @@ ], "challengeType": 0, "type": "waypoint" + }, + { + "id": "bb000000000000000000002", + "title": "Convert json data to html", + "difficulty": 3.21, + "description": [ + "", + "Now that we have the data let's re-arrange it so that ", + "", + "", + "  json.map(function(val){", + "    ", + "    html = html + \"<div class = 'cat'>\"", + "    ", + "    for(var key in val){", + "      html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", + "  }", + "    ", + "    html = html + \"</div><br/>\"", + "    ", + "  });", + "", + "" + ], + "tests": [ + "assert($(\".message\").html() !== '', 'The message box should have something in it')", + "assert($(\".message div\").html() !== undefined, 'you should have made created some sort of view from the json data')" + ], + "challengeSeed": [ + "fccss", + " $(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + " ", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
", + "
", + "

Cat Photo Finder

", + "
", + "
", + "
", + "
", + " The message will go here","
", + "
", + "
", + "
", + "
", + " ", + "
", + "
", + "
" + ], + "challengeType": 0, + "type": "waypoint" } ] } diff --git a/seed/under-construction/json-apis-and-ajax.json b/seed/under-construction/json-apis-and-ajax.json deleted file mode 100644 index ab12090b02..0000000000 --- a/seed/under-construction/json-apis-and-ajax.json +++ /dev/null @@ -1,535 +0,0 @@ -{ - "name": "JSON APIs and Ajax", - "order": 0.0065, - "challenges": [ - { - "id": "bad87fed1348bd9aeca08826", - "title": "Trigger on click Events with jQuery", - "difficulty": 3.19, - "description": [ - "With jQuery we are able to get data from APIs via Ajax", - "This data normally comes in the form of JSON", - "Let's get the Get Message button to set the text of a div", - "We will later use this to display the result of out API request", - "$(\"#getMessage\").on(\"click\", function(){", - "  $(\".message\").html(\"Here is the message\");", - "});" - ], - "tests": [ - "assert(editor.match(/\\$\\(\\s?\\\"\\#getMessage\\\"\\s?\\)\\.on\\s?\\(\\s?\\\"click\\\"\\,\\s?function\\s?\\(\\)\\s?\\{/gi), 'You should have bound the click event to the getMessage button')", - "assert(editor.match(/\\$\\(\\s?\\\"\\.message\\\"\\s?\\)\\.html\\(\\s?\\\"Here\\sis\\sthe\\smessage\\\"\\s?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", - "assert(editor.match(/\\}\\);/gi) && editor.match(/\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " ", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "

Cat Photo Finder

", - "
", - "
", - "
", - "
", - " The message will go here", - "
", - "
", - "
", - "
", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - { - "id": "bad87fee1348bd9aebc08726", - "title": "Learn JSON Syntax", - "description": [ - "JSON stands for \"JavaScript Object Notation\". It\"s how you create objects in JavaScript.", - "JSON is a series of \"key-value pairs\". Everything on the left of the colon (:) is the \"key\" you use to unlock the \"value\" on the right of the colon." - ], - "tests": [ - "assert(typeof data != \"undefined\", \"Whoops! It looks like you deleted the data variable!\");", - "assert(typeof getAnId != \"undefined\", \"Whoops! It looks like you deleted the getAnId function!\");", - "assert(data[0]['id'] === getAnId(), \"The duntion getFirstId should return the id of the first element in the array\");" - ], - "challengeSeed": [ - "fccss", - "var data = [", - " {", - " \"id\": 0,", - " \"imageLink\": \"http://rs611.pbsrc.com/albums/tt194/allypopper423/Funny-Cat-Green-Avacado.jpg~c200\",", - " \"codeNames\": [", - " \"Juggernaut\",", - " \"Mrs. Wallace\",", - " \"Buttercup\"", - " ]", - " },", - " {", - " \"id\": 1,", - " \"imageLink\": \"http://cdn.grumpycats.com/wp-content/uploads/2012/09/GC-Gravatar-copy.png\",", - " \"codeNames\": [", - " \"Oscar\",", - " \"Scrooge\",", - " \"Tyrion\"", - " ]", - " },", - " {", - " \"id\": 2,", - " \"imageLink\": \"http://www.kittenspet.com/wp-content/uploads/2012/08/cat_with_funny_face_3-200x200.jpg\",", - " \"codeNames\": [", - " \"The Doctor\",", - " \"Loki\",", - " \"Joker\"", - " ]", - " }", - "]", - "function getAnId(){", - " return();", - "}", - "fcces" - ], - "challengeType": 0, - "type": "waypoint" - }, - { - "id": "bad87fee1348bd9aeca08826", - "title": "Displaying JSON data in HTML", - "difficulty": 3.19, - "description": [ - "JSON stands for \"JavaScript Object Notation\". It\"s how you create objects in JavaScript.", - "JSON is a series of \"key-value pairs\". Everything on the left of the colon (:) is the \"key\" you use to unlock the \"value\" on the right of the colon." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"#getMessage\").on(\"click\", function(){", - " $(\".message\").html(\"Here is the message\");", - " });", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "

Cat Photo Finder

", - "
", - "
", - "
", - "
", - " The message will go here", - "
", - "
", - "
", - "
", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc48826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " });", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "
", - " ", - "
", - "
", - "

#check-me

", - "
", - " ", - " Is the checkbox checked?", - " ", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc38826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text(\"happy text\");", - " });", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "
", - " ", - "
", - "
", - "

#check-me

", - "
", - " ", - " Is the checkbox checked?", - " ", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc28826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - "Let's make everything roll with rollOut." - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text($(\"#check-me\").prop(\"checked\"));", - " });", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "
", - " ", - "
", - "
", - "

#check-me

", - "
", - " ", - " Is the checkbox checked?", - " ", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad84fee1348bd9aecc18826", - "title": "Read Data from an Element Using jQuery", - "dashedName": "waypoint-read-data-from-an-element-using-jquery", - "difficulty": 3.17, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " $(document).ready(function() {", - " $(\"button\").on(\"click\", function() {", - " $(\"#click-me\").addClass(\"animated shake\");", - " $(\"#checked-state\").text($(\"#check-me\").prop(\"checked\"));", - " });", - " });", - "fcces", - "", - "", - "", - "
", - "
", - "
", - " ", - "
", - "
", - "

#check-me

", - "
", - " ", - " Is the checkbox checked?", - " ", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9aecc08826", - "title": "Trigger onHover Events with jQuery", - "dashedName": "waypoint-trigger-onhover-events-with-jquery", - "difficulty": 3.18, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9aebc08826", - "title": "Get Data from an URL Using jQuery", - "dashedName": "waypoint-get-data-from-a-url-using-jquery", - "difficulty": 3.21, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - "", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad87fee1348bd9ae9c08826", - "title": "Loop through JSON Data Using jQuery", - "dashedName": "waypoint-loop-through-json-data-using-jquery", - "difficulty": 3.22, - "description": [ - - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - "", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08726", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - "", - " });", - " });", - "", - " });", - "fcces", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08626", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " });", - " });", - "", - " });", - "fcces", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08526", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " $(\"\").appendTo(\"#output\");", - " });", - " });", - "", - " });", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - }, - - { - "id": "bad88fee1348bd9ae8c08426", - "title": "Wire AJAX Call into a jQuery Click Event", - "dashedName": "waypoint-wire-ajax-call-into-a-jquery-click-event", - "difficulty": 3.24, - "description": [ - "" - ], - "tests": [ - - ], - "challengeSeed": [ - "fccss", - " var random = function() { return Math.floor(Math.random() * 3) }", - " $(document).ready(function() {", - "", - " $(\"#cat-button\").on(\"click\", function() {", - " $.getJSON(\"/json/cats.json\", function( json ) {", - " var kitten = json[random()];", - " $(\"\").appendTo(\"#output\");", - " $(\"

Code name: \" + kitten.codeNames[random()] + \"

\").appendTo(\"#output\");", - " });", - " });", - "", - " });", - "fcces", - "
", - " ", - "
", - "
", - "
" - ], - "challengeType": 0, - "type": "waypoint" - } - ] -} From 1b13ad2601452eb83364fd00f9c998a2d9f91802 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Wed, 30 Sep 2015 23:23:58 +0100 Subject: [PATCH 013/118] Added the skeleton for the fourth challenge. Challenge three needs some refinement in the testing system --- seed/challenges/json-apis-and-ajax.json | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 9f96865672..e826927a0d 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -113,7 +113,7 @@ }, { "id": "bb000000000000000000002", - "title": "Convert json data to html", + "title": "Convert JSON data to HTML", "difficulty": 3.21, "description": [ "", @@ -184,6 +184,25 @@ ], "challengeType": 0, "type": "waypoint" + }, + { + "id": "bb000000000000000000003", + "title": "Pre-filtering the JSON", + "difficulty": 3.22, + "description": [ + "", + "If we want to filter the data we have so that we are searching through results based on users inout. It is far more efficient to filter and display a copy of the data we have instead of requesting a new copy each time.", + "This means we should never hit API limits and it will make the process more efficient.", + "" + ], + "tests": [ + "/*be assertive!*/" + ], + "challengeSeed": [ + "TODO: get the result of the previous challenge" + ], + "challengeType": 0, + "type": "waypoint" } ] } From 4e33b355b0e947b015cf8526e85a355b29b51388 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Sat, 3 Oct 2015 23:59:54 +0100 Subject: [PATCH 014/118] 90% complete without QA or refined descriptions/tests --- seed/challenges/json-apis-and-ajax.json | 223 ++++++++++++++++++++++-- 1 file changed, 213 insertions(+), 10 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index e826927a0d..fda516722e 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -4,6 +4,29 @@ "challenges": [ { "id": "bb000000000000000000000", + "title": "Understanding JSON", + "difficulty": 3.19, + "description": [ + "", + "JSON is a way of creating a file or a db record from a javascript object.", + "JSON works in the exact same way as javascript objects that you should be familiar with.", + "" + ], + "tests": [ + "assert(typeof json !== 'undefined')" + ], + "challengeSeed": [ + "var json = {", + " name: \"Happy Camper\"", + " age: 35", + " height: \"5ft 8\"", + "}" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ @@ -53,7 +76,7 @@ "type": "waypoint" }, { - "id": "bb000000000000000000001", + "id": "bb000000000000000000002", "title": "Creating HTML from Data from an AJAX request Using jQuery", "difficulty": 3.20, "description": [ @@ -112,7 +135,7 @@ "type": "waypoint" }, { - "id": "bb000000000000000000002", + "id": "bb000000000000000000003", "title": "Convert JSON data to HTML", "difficulty": 3.21, "description": [ @@ -135,8 +158,7 @@ "" ], "tests": [ - "assert($(\".message\").html() !== '', 'The message box should have something in it')", - "assert($(\".message div\").html() !== undefined, 'you should have made created some sort of view from the json data')" + "assert($(\".message\").html() !== '', 'The message box should have something in it')" ], "challengeSeed": [ "fccss", @@ -149,10 +171,12 @@ " ", " //Add you code to modify the data here. It should add it to the html sting for use in the view", " ", - " ", - " ", " //Don't modify above here", " ", + " ", + " ", + " //Don't modify below here", + " ", "     $(\".message\").html(html);", " ", "   });", @@ -186,20 +210,199 @@ "type": "waypoint" }, { - "id": "bb000000000000000000003", + "id": "bb000000000000000000004", + "title": "render those images!", + "difficulty": 3.22, + "description": [ + "", + "instead of just placing everything in a div we should check if the value is an image.", + "If it is an image we should use it as an ima tag instead so that the image is rendered", + "", + "if(key === \"imageLink\"){", + "html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';", + "}", + "else{", + " html = html + '<div class = \"' + key + '\">' + val[key] + '</div>';", + "}", + "", + "" + ], + "tests": [ + "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object')" + ], + "challengeSeed": [ + "fccss", + "$(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + "  json.map(function(val){", + "", + " html = html + \"
\"", + "", + "", + "", + " for(var key in val){", + "", + " //Don't modify above here", + " ", + " ", + " ", + " //Don't modify below here", + "", + " }", + " ", + " html = html + \"

\"", + "", + " });", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
", + "
", + "

Cat Photo Finder

", + "
", + "
", + "
", + "
", + " The message will go here", + "
", + "
", + "
", + "
", + "
", + " ", + "
", + "
", + "
", + "" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000005", "title": "Pre-filtering the JSON", "difficulty": 3.22, "description": [ "", - "If we want to filter the data we have so that we are searching through results based on users inout. It is far more efficient to filter and display a copy of the data we have instead of requesting a new copy each time.", "This means we should never hit API limits and it will make the process more efficient.", + "Let's try pre-filtering the json before we map it", + "We can use the pre-made filter method like this to remove the cat with the id of 1", + "", + "json = json.filter(function(val){", + " return(val.id !== 1);", + "});", + "", "" ], "tests": [ - "/*be assertive!*/" + "assert(editor.match(/filter/gi), 'You should be making use of the .filter method')" ], "challengeSeed": [ - "TODO: get the result of the previous challenge" + "fccss", + "$(document).ready(function() {", + " ", + " $(\"#getMessage\").on(\"click\", function() {", + "   $.getJSON(\"/json/cats.json?callback=\", function( json ) {", + " ", + " var html = \"\";", + " ", + " //Add you code to modify the data here. It should add it to the html sting for use in the view", + " ", + "  json.map(function(val){", + "", + "    val = \"\" ", + "", + " html = html + \"
\"", + "", + " //Don't modify above here", + " ", + " ", + " ", + " //Don't modify below here", + "", + " for(var key in val){", + "", + " html = html + '
' + val[key] + '
';", + "", + " }", + "", + " ", + " html = html + \"

\"", + "", + " });", + " ", + " //Don't modify above here", + " ", + "     $(\".message\").html(html);", + " ", + "   });", + " });", + " ", + " });", + "fcces", + "", + "", + "", + "
", + "
", + "

Cat Photo Finder

", + "
", + "
", + "
", + "
", + " The message will go here", + "
", + "
", + "
", + "
", + "
", + " ", + "
", + "
", + "
", + "" + ], + "challengeType": 0, + "type": "waypoint" + }, + { + "id": "bb000000000000000000006", + "title": "Getting Geo-location data for use in APIs", + "difficulty": 3.19, + "description": [ + "", + "Be descriptive!" + ], + "tests": [ + "/*Be Assertive*/')" + ], + "challengeSeed": [ + "var json = {", + " name: \"Happy Camper\"", + " age: 35", + " height: \"5ft 8\"", + "}" ], "challengeType": 0, "type": "waypoint" From 89e1ebb952e1ce407b293acba40487196d1bb579 Mon Sep 17 00:00:00 2001 From: SaintPeter Date: Sat, 3 Oct 2015 19:56:10 -0700 Subject: [PATCH 015/118] New for loop waypoints and verbiage improvements --- seed/challenges/basic-javascript.json | 88 ++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index c10af0def1..2dbe909815 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -790,6 +790,14 @@ "description":[ "You can run the same code multiple times by using a loop.", "The most common type of JavaScript loop is called a \"for loop\" because it runs \"for\" a specific number of times.", + "", + "For loops are declared with three optional expressions seperated by semicolons:", + "for([initialization]; [condition]; [final-expression])", + "The initialization statement is executed one time only before the loop starts. It is typically used to define and setup your loop varaible.", + "The condition statement is evaluated at the beginning of every loop and will continue as long as it evalutes true. When condition is false at the start of the loop, the loop will stop executing. This means if condition starts as false, your loop will never execute.", + "The final-expression is executed at the end of each loop iteration, prior to the next condition check and is usually used to increment or decrement your loop counter.", + "", + "We'll initialize with i = 0 and loop while our condition i < 5 is true. We'll increment i by 1 each loop with i++ as our final-expression.", "var ourArray = [];", "for(var i = 0; i < 5; i++) {", "  ourArray.push(i);", @@ -798,7 +806,7 @@ "Let's try getting a for loop to work by pushing values to an array." ], "tests":[ - "assert(editor.getValue().match(/for/g), 'message: You should be using a for loop for this.');", + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", "assert.deepEqual(myArray, [0,1,2,3,4], 'message: myArray should equal [0,1,2,3,4].');" ], "challengeSeed":[ @@ -821,6 +829,84 @@ "type": "waypoint", "challengeType": 1 }, + { + "id":"56104e9e514f539506016a5c", + "title": "Iterate Odd Numbers With a For Loop", + "difficulty":"9.9824", + "description":[ + "For loops don't have to iterate one at a time. By changing our final-expression, we can count by even numbers.", + "We'll start at i = 0 and loop while i < 10. We'll increment i by 2 each loop with i += 2.", + "var ourArray = [];", + "for(var i = 0; i < 10; i += 2) {", + "  ourArray.push(i);", + "}", + "ourArray will now contain [0,2,4,6,8] ", + "Let's change our initialization and final-expression so we can count by odd numbers." + ], + "tests":[ + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", + "assert.deepEqual(myArray, [1,3,5,7,9], 'message: myArray should equal [1,3,5,7,9].');" + ], + "challengeSeed":[ + "ourArray = [];", + "for(var i = 1; i < 10; i += 2){", + " ourArray.push(i);", + "}", + "var myArray = [];", + "", + "// Only change code below this line.", + "", + "// Push the odd numbers from one through nine to myArray using a \"for loop\" like above.", + "", + "// Only change code above this line.", + "// We use this function to show you the value of your variable in your output box.", + "// You'll learn about functions soon.", + "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", + "" + ], + "type": "waypoint", + "challengeType": 1 + }, + { + "id":"56105e7b514f539506016a5e", + "title": "Count Backwards With a For Loop", + "difficulty":"9.9824", + "description":[ + "A for loop can also count backwards, so long as we can define the right conditions.", + "", + "In order to count backwards by twos, we'll need to change our initialization, condition, and final-expression.", + "We'll start at i = 10 and loop while i > 0. We'll decrement i by 2 each loop with i -= 2.", + "var ourArray = [];", + "for(var i = 10; i > 0; i -= 2) {", + "  ourArray.push(i);", + "}", + "ourArray will now contain [10,8,6,4,2] ", + "Let's change our initialization and final-expression so we can count backward by twos for numbers." + ], + "tests":[ + "assert(editor.getValue().match(/for\\s*\\(/g).length > 1, 'message: You should be using a for loop for this.');", + "assert.deepEqual(myArray, [9,7,5,3,1], 'message: myArray should equal [9,7,5,3,1].');" + ], + "challengeSeed":[ + "ourArray = [];", + "for(var i = 9; i > 0; i -= 2){", + " ourArray.push(i);", + "}", + "var myArray = [];", + "", + "// Only change code below this line.", + "", + "// Push the odd numbers from nine through one to myArray using a \"for loop\" like above.", + "", + "// Only change code above this line.", + "// We use this function to show you the value of your variable in your output box.", + "// You'll learn about functions soon.", + "if(typeof(myArray) !== \"undefined\"){(function(){return myArray;})();}", + "" + ], + "type": "waypoint", + "challengeType": 1 + }, { "id":"cf1111c1c11feddfaeb1bdef", "title": "Iterate with JavaScript While Loops", From fe3e94e69b5005d8c16dfac008a3e785065d5174 Mon Sep 17 00:00:00 2001 From: Abhisek Pattnaik Date: Mon, 21 Sep 2015 01:55:21 +0530 Subject: [PATCH 016/118] Modify tests for Bonfire - Where do I belong close FreeCodeCamp/FreeCodeCamp#3381 --- seed/challenges/basic-bonfires.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json index 931c157ce1..c81733da04 100644 --- a/seed/challenges/basic-bonfires.json +++ b/seed/challenges/basic-bonfires.json @@ -617,8 +617,8 @@ "assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: where([10, 20, 30, 40, 50], 35) should return 3.');", "assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: where([10, 20, 30, 40, 50], 30) should return 2.');", "assert(where([40, 60], 50) === 1, 'message: where([40, 60,], 50) should return 1.');", - "assert(where([5, 3, 20, 3], 3) === 0, 'message: where([5, 3, 20, 3], 3) should return 0.');", - "assert(where([2, 20, 10], 1) === 0, 'message: where([2, 20, 10], 1) should return 0.');", + "assert(where([5, 3, 20, 3], 5) === 2, 'message: where([5, 3, 20, 3], 5) should return 2.');", + "assert(where([2, 20, 10], 19) === 2, 'message: where([2, 20, 10], 19) should return 2.');", "assert(where([2, 5, 10], 15) === 3, 'message: where([2, 5, 10], 15) should return 3.');" ], "type": "bonfire", From 5b771e18e66eb53157acd1bc10d8d90ce4951e0a Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 5 Oct 2015 22:46:29 +0100 Subject: [PATCH 017/118] Finished the geolocation waypoint. Ready for QA and copy fixes --- seed/challenges/json-apis-and-ajax.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index fda516722e..cec38c8b65 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -392,10 +392,22 @@ "difficulty": 3.19, "description": [ "", - "Be descriptive!" + "We can access the users current location by using the built in navigator in the browser.", + "The navigator will get the users current longitude and latitude with a decent level of accuracy.", + "", + "if (navigator.geolocation) {", + " navigator.geolocation.getCurrentPosition(function(position){", + " // Do something in here with the coordinates!", + " ", + " console.log(\"latitiude\", position.coords.latitude);", + " console.log(\"longitude\", position.coords.longitude);", + " ", + " });", + "}", + "" ], "tests": [ - "/*Be Assertive*/')" + "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" ], "challengeSeed": [ "var json = {", From da09a7b650ab40b316dc42c64978dda76999b21b Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Mon, 5 Oct 2015 23:42:30 +0100 Subject: [PATCH 018/118] Brought in line with staging and added spoofigator! --- client/commonFramework.js | 14 ++++++++++++++ seed/challenges/json-apis-and-ajax.json | 25 +++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/client/commonFramework.js b/client/commonFramework.js index 8abcb6a9dc..ced143db58 100644 --- a/client/commonFramework.js +++ b/client/commonFramework.js @@ -481,6 +481,20 @@ function safeHTMLRun(test) { // add feuxQuery s = 'var document = \"\"; var $ = function() {return(new function() {this.add=function() {return(this);};this.addBack=function() {return(this);};this.addClass=function() {return(this);};this.after=function() {return(this);};this.ajaxComplete=function() {return(this);};this.ajaxError=function() {return(this);};this.ajaxSend=function() {return(this);};this.ajaxStart=function() {return(this);};this.ajaxStop=function() {return(this);};this.ajaxSuccess=function() {return(this);};this.andSelf=function() {return(this);};this.animate=function() {return(this);};this.append=function() {return(this);};this.appendTo=function() {return(this);};this.attr=function() {return(this);};this.before=function() {return(this);};this.bind=function() {return(this);};this.blur=function() {return(this);};this.callbacksadd=function() {return(this);};this.callbacksdisable=function() {return(this);};this.callbacksdisabled=function() {return(this);};this.callbacksempty=function() {return(this);};this.callbacksfire=function() {return(this);};this.callbacksfired=function() {return(this);};this.callbacksfireWith=function() {return(this);};this.callbackshas=function() {return(this);};this.callbackslock=function() {return(this);};this.callbackslocked=function() {return(this);};this.callbacksremove=function() {return(this);};this.change=function() {return(this);};this.children=function() {return(this);};this.clearQueue=function() {return(this);};this.click=function() {return(this);};this.clone=function() {return(this);};this.closest=function() {return(this);};this.contents=function() {return(this);};this.context=function() {return(this);};this.css=function() {return(this);};this.data=function() {return(this);};this.dblclick=function() {return(this);};this.delay=function() {return(this);};this.delegate=function() {return(this);};this.dequeue=function() {return(this);};this.detach=function() {return(this);};this.die=function() {return(this);};this.each=function() {return(this);};this.empty=function() {return(this);};this.end=function() {return(this);};this.eq=function() {return(this);};this.error=function() {return(this);};this.fadeIn=function() {return(this);};this.fadeOut=function() {return(this);};this.fadeTo=function() {return(this);};this.fadeToggle=function() {return(this);};this.filter=function() {return(this);};this.find=function() {return(this);};this.finish=function() {return(this);};this.first=function() {return(this);};this.focus=function() {return(this);};this.focusin=function() {return(this);};this.focusout=function() {return(this);};this.get=function() {return(this);};this.has=function() {return(this);};this.hasClass=function() {return(this);};this.height=function() {return(this);};this.hide=function() {return(this);};this.hover=function() {return(this);};this.html=function() {return(this);};this.index=function() {return(this);};this.innerHeight=function() {return(this);};this.innerWidth=function() {return(this);};this.insertAfter=function() {return(this);};this.insertBefore=function() {return(this);};this.is=function() {return(this);};this.jQuery=function() {return(this);};this.jquery=function() {return(this);};this.keydown=function() {return(this);};this.keypress=function() {return(this);};this.keyup=function() {return(this);};this.last=function() {return(this);};this.length=function() {return(this);};this.live=function() {return(this);};this.load=function() {return(this);};this.load=function() {return(this);};this.map=function() {return(this);};this.mousedown=function() {return(this);};this.mouseenter=function() {return(this);};this.mouseleave=function() {return(this);};this.mousemove=function() {return(this);};this.mouseout=function() {return(this);};this.mouseover=function() {return(this);};this.mouseup=function() {return(this);};this.next=function() {return(this);};this.nextAll=function() {return(this);};this.nextUntil=function() {return(this);};this.not=function() {return(this);};this.off=function() {return(this);};this.offset=function() {return(this);};this.offsetParent=function() {return(this);};this.on=function() {return(this);};this.one=function() {return(this);};this.outerHeight=function() {return(this);};this.outerWidth=function() {return(this);};this.parent=function() {return(this);};this.parents=function() {return(this);};this.parentsUntil=function() {return(this);};this.position=function() {return(this);};this.prepend=function() {return(this);};this.prependTo=function() {return(this);};this.prev=function() {return(this);};this.prevAll=function() {return(this);};this.prevUntil=function() {return(this);};this.promise=function() {return(this);};this.prop=function() {return(this);};this.pushStack=function() {return(this);};this.queue=function() {return(this);};this.ready=function() {return(this);};this.remove=function() {return(this);};this.removeAttr=function() {return(this);};this.removeClass=function() {return(this);};this.removeData=function() {return(this);};this.removeProp=function() {return(this);};this.replaceAll=function() {return(this);};this.replaceWith=function() {return(this);};this.resize=function() {return(this);};this.scroll=function() {return(this);};this.scrollLeft=function() {return(this);};this.scrollTop=function() {return(this);};this.select=function() {return(this);};this.selector=function() {return(this);};this.serialize=function() {return(this);};this.serializeArray=function() {return(this);};this.show=function() {return(this);};this.siblings=function() {return(this);};this.size=function() {return(this);};this.slice=function() {return(this);};this.slideDown=function() {return(this);};this.slideToggle=function() {return(this);};this.slideUp=function() {return(this);};this.stop=function() {return(this);};this.submit=function() {return(this);};this.text=function() {return(this);};this.toArray=function() {return(this);};this.toggle=function() {return(this);};this.toggle=function() {return(this);};this.toggleClass=function() {return(this);};this.trigger=function() {return(this);};this.triggerHandler=function() {return(this);};this.unbind=function() {return(this);};this.undelegate=function() {return(this);};this.unload=function() {return(this);};this.unwrap=function() {return(this);};this.val=function() {return(this);};this.width=function() {return(this);};this.wrap=function() {return(this);};this.wrapAll=function() {return(this);};this.wrapInner=function() {return(this);}});};$.ajax=function() {return($);};$.ajaxPrefilter=function() {return($);};$.ajaxSetup=function() {return($);};$.ajaxTransport=function() {return($);};$.boxModel=function() {return($);};$.browser=function() {return($);};$.Callbacks=function() {return($);};$.contains=function() {return($);};$.cssHooks=function() {return($);};$.cssNumber=function() {return($);};$.data=function() {return($);};$.Deferred=function() {return($);};$.dequeue=function() {return($);};$.each=function() {return($);};$.error=function() {return($);};$.extend=function() {return($);};$.fnextend=function() {return($);};$.fxinterval=function() {return($);};$.fxoff=function() {return($);};$.get=function() {return($);};$.getJSON=function() {return($);};$.getScript=function() {return($);};$.globalEval=function() {return($);};$.grep=function() {return($);};$.hasData=function() {return($);};$.holdReady=function() {return($);};$.inArray=function() {return($);};$.isArray=function() {return($);};$.isEmptyObject=function() {return($);};$.isFunction=function() {return($);};$.isNumeric=function() {return($);};$.isPlainObject=function() {return($);};$.isWindow=function() {return($);};$.isXMLDoc=function() {return($);};$.makeArray=function() {return($);};$.map=function() {return($);};$.merge=function() {return($);};$.noConflict=function() {return($);};$.noop=function() {return($);};$.now=function() {return($);};$.param=function() {return($);};$.parseHTML=function() {return($);};$.parseJSON=function() {return($);};$.parseXML=function() {return($);};$.post=function() {return($);};$.proxy=function() {return($);};$.queue=function() {return($);};$.removeData=function() {return($);};$.sub=function() {return($);};$.support=function() {return($);};$.trim=function() {return($);};$.type=function() {return($);};$.unique=function() {return($);};$.when=function() {return($);};$.always=function() {return($);};$.done=function() {return($);};$.fail=function() {return($);};$.isRejected=function() {return($);};$.isResolved=function() {return($);};$.notify=function() {return($);};$.notifyWith=function() {return($);};$.pipe=function() {return($);};$.progress=function() {return($);};$.promise=function() {return($);};$.reject=function() {return($);};$.rejectWith=function() {return($);};$.resolve=function() {return($);};$.resolveWith=function() {return($);};$.state=function() {return($);};$.then=function() {return($);};$.currentTarget=function() {return($);};$.data=function() {return($);};$.delegateTarget=function() {return($);};$.isDefaultPrevented=function() {return($);};$.isImmediatePropagationStopped=function() {return($);};$.isPropagationStopped=function() {return($);};$.metaKey=function() {return($);};$.namespace=function() {return($);};$.pageX=function() {return($);};$.pageY=function() {return($);};$.preventDefault=function() {return($);};$.relatedTarget=function() {return($);};$.result=function() {return($);};$.stopImmediatePropagation=function() {return($);};$.stopPropagation=function() {return($);};$.target=function() {return($);};$.timeStamp=function() {return($);};$.type=function() {return($);};$.which=function() {return($);};' + s; + // add spoofigator + + s = " var navigator = " + + "function(){" + + " this.geolocation=function(){" + + " this.getCurrentPosition=function(){" + + " this.coords = {latitude: \"\", longitude: \"\"};" + + " return(this);" + + " };" + + " return(this);" + + " };" + + " return(this);" + + "};" + s; + sandBox.submit(scopejQuery(s), function(cls, message) { if (cls) { console.log(message.error); diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index cec38c8b65..9ea8bfd0e8 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -396,13 +396,12 @@ "The navigator will get the users current longitude and latitude with a decent level of accuracy.", "", "if (navigator.geolocation) {", - " navigator.geolocation.getCurrentPosition(function(position){", - " // Do something in here with the coordinates!", - " ", - " console.log(\"latitiude\", position.coords.latitude);", - " console.log(\"longitude\", position.coords.longitude);", - " ", - " });", + "  navigator.geolocation.getCurrentPosition(function(position){", + "    // Do something in here with the coordinates!", + "    ", + "    $(\"#data\").html(\"latitiude\" + position.coords.latitude + \"longitude\" + position.coords.longitude);", + "    ", + "  });", "}", "" ], @@ -410,11 +409,13 @@ "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" ], "challengeSeed": [ - "var json = {", - " name: \"Happy Camper\"", - " age: 35", - " height: \"5ft 8\"", - "}" + "fccss", + "", + "fcces", + "
", + "

You are here!

", + " ", + "
" ], "challengeType": 0, "type": "waypoint" From 9f298cbe9409dbd49b427bb0a1855fd3b0df1930 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Tue, 6 Oct 2015 21:47:29 +0100 Subject: [PATCH 019/118] Fixed tests --- seed/challenges/json-apis-and-ajax.json | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index 9ea8bfd0e8..de5feb033c 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -10,19 +10,18 @@ "", "JSON is a way of creating a file or a db record from a javascript object.", "JSON works in the exact same way as javascript objects that you should be familiar with.", - "" + "Lets add a string property to out object." ], "tests": [ - "assert(typeof json !== 'undefined')" + "assert(typeof json !== 'undefined' && Object.keys(json).length === 3 && typeof(json[Object.keys(json)[Object.keys(json).length-1]]) === 'string', 'message: You should have added a string value to your object.')" ], "challengeSeed": [ "var json = {", - " name: \"Happy Camper\"", - " age: 35", - " height: \"5ft 8\"", + " \"name\": \"Happy Camper\"", + " \"height\": \"160cm\"", "}" ], - "challengeType": 0, + "challengeType": 1, "type": "waypoint" }, { @@ -158,8 +157,8 @@ "" ], "tests": [ - "assert($(\".message\").html() !== '', 'The message box should have something in it')" - ], + "assert(/json\\.map/gi, 'The message box should have something in it')" + ], "challengeSeed": [ "fccss", " $(document).ready(function() {", From a27aa2d9f62e373b689684724a17a485df1139f2 Mon Sep 17 00:00:00 2001 From: benmcmahon100 Date: Tue, 6 Oct 2015 22:54:20 +0100 Subject: [PATCH 020/118] More test and copy fixes. Removed weird bugged challenge --- seed/challenges/json-apis-and-ajax.json | 64 ++++++++----------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index de5feb033c..c522e2441b 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -2,45 +2,23 @@ "name": "JSON APIs and Ajax", "order": 0.0065, "challenges": [ - { - "id": "bb000000000000000000000", - "title": "Understanding JSON", - "difficulty": 3.19, - "description": [ - "", - "JSON is a way of creating a file or a db record from a javascript object.", - "JSON works in the exact same way as javascript objects that you should be familiar with.", - "Lets add a string property to out object." - ], - "tests": [ - "assert(typeof json !== 'undefined' && Object.keys(json).length === 3 && typeof(json[Object.keys(json)[Object.keys(json).length-1]]) === 'string', 'message: You should have added a string value to your object.')" - ], - "challengeSeed": [ - "var json = {", - " \"name\": \"Happy Camper\"", - " \"height\": \"160cm\"", - "}" - ], - "challengeType": 1, - "type": "waypoint" - }, { "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", "difficulty": 3.19, "description": [ - "With jQuery we are able to get data from APIs via Ajax", - "This data normally comes in the form of JSON", - "Let's get the Get Message button to set the text of a div", - "We will later use this to display the result of out API request", + "With jQuery we are able to get data from APIs via Ajax.", + "This data normally comes in the form of JSON.", + "Let's get the Get Message button to set the text of a div.", + "We will later use this to display the result of out API request.", "$(\"#getMessage\").on(\"click\", function(){", "  $(\".message\").html(\"Here is the message\");", "});" ], "tests": [ - "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button')", - "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description')", - "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions')" + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\#getMessage(?:'|\")\\s*?\\)\\s*?\\.on\\s*?\\(\\s*?(?:'|\")click(?:'|\")\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have bound the click event to the getMessage button.')", + "assert(editor.match(/\\$\\s*?\\(\\s*?(?:'|\")\\.message(?:'|\")\\s*?\\)\\s*?\\.html\\s*?\\(\\s*?(?:'|\")Here\\sis\\sthe\\smessage(?:'|\")\\s*?\\);/gi), 'You should set te value of the #message box to be the message given in the description.')", + "assert(editor.match(/\\n*?\\s*?\\}\\n*?\\s*?\\);/gi) && editor.match(/\\n*?\\s*?\\}\\);/gi).length >= 2, 'Make sure that you close off all of your functions.')" ], "challengeSeed": [ "fccss", @@ -87,15 +65,15 @@ "    $(\".message\").html(JSON.stringify(json))", "  });", "});
", - "Let's make it so that the data sent from the request is appended to the .message div", + "Let's make it so that the data sent from the request is appended to the .message div.", "" ], "tests": [ - "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request')", - "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis')", - "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis')", - "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file')", - "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON')" + "assert(editor.match(/\\$\\s*?\\(\\s*?(\\\"|\\')\\#getMessage(\\\"|\\')\\s*?\\)\\s*?\\.\\s*?on\\s*?\\(\\s*?(\\\"|\\')click(\\\"|\\')\\s*?\\,\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/gi), 'You should have a click handler on the getMessage button to trigger the AJAX request.')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi), 'You should have at least on closing set of brackets and parenthesis.')", + "assert(editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi) && editor.match(/\\,\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi) && editor.match(/\\s*?\\}\\s*?\\)\\s*?\\;/gi).length === editor.match(/\\s*?function\\s*?\\(\\s*?\\w*?\\s*?\\)\\s*?\\{/gi).length, 'Each callback function should have a closing set of brackets and parenthesis.')", + "assert(editor.match(/\\$\\s*?\\.\\s*?getJSON\\s*?\\(\\s*?\"\\\/json\\\/cats\\.json\\?callback\\=\"\\s*?\\,\\s*?function\\s*?\\(\\s*?json\\s*?\\)\\s*?\\{/gi), 'You should be making use of the getJSON method given in the description to load data from the json file.')", + "assert(editor.match(/\\$\\s*?\\(\\s*?\\\"\\.message\\\"\\s*?\\)\\s*?\\.\\s*?html\\s*?\\(\\s*?JSON\\s*?\\.\\s*?stringify\\s*?\\(\\s*?json\\s*?\\)\\s*?\\)/gi), 'Don\\'t forget to make the .html change the contents of the message box so that it contains the result of the getJSON.')" ], "challengeSeed": [ "fccss", @@ -139,7 +117,7 @@ "difficulty": 3.21, "description": [ "", - "Now that we have the data let's re-arrange it so that ", + "Now that we have the data let's re-arrange it so that it can be displayed in a user friendly way.", "", "", "  json.map(function(val){", @@ -157,7 +135,7 @@ "" ], "tests": [ - "assert(/json\\.map/gi, 'The message box should have something in it')" + "assert(/json\\.map/gi, 'The message box should have something in it.')" ], "challengeSeed": [ "fccss", @@ -215,7 +193,7 @@ "description": [ "", "instead of just placing everything in a div we should check if the value is an image.", - "If it is an image we should use it as an ima tag instead so that the image is rendered", + "If it is an image we should use it as an ima tag instead so that the image is rendered.", "", "if(key === \"imageLink\"){", "html = html + '<img class = \"' + key + '\"src = \"' + val[key] + '\">';", @@ -227,7 +205,7 @@ "" ], "tests": [ - "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object')" + "assert(editor.match(/imageLink/gi), 'You should have accessed the imageLink of each cat object.')" ], "challengeSeed": [ "fccss", @@ -303,8 +281,8 @@ "description": [ "", "This means we should never hit API limits and it will make the process more efficient.", - "Let's try pre-filtering the json before we map it", - "We can use the pre-made filter method like this to remove the cat with the id of 1", + "Let's try pre-filtering the json before we map it.", + "We can use the pre-made filter method like this to remove the cat with the id of 1.", "", "json = json.filter(function(val){", " return(val.id !== 1);", @@ -313,7 +291,7 @@ "" ], "tests": [ - "assert(editor.match(/filter/gi), 'You should be making use of the .filter method')" + "assert(editor.match(/filter/gi), 'You should be making use of the .filter method.')" ], "challengeSeed": [ "fccss", @@ -405,7 +383,7 @@ "" ], "tests": [ - "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location')" + "assert(editor.match(/navigator\\.geolocation\\.getCurrentPosition/gi), 'you should make use of the navigator.geolocation to access the users current location.')" ], "challengeSeed": [ "fccss", From 56b7b6f29bd8979f3e7cab5b3419ba8e2752b18a Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 6 Oct 2015 15:37:43 -0700 Subject: [PATCH 021/118] improve markup and titles of challenges --- seed/challenges/json-apis-and-ajax.json | 145 ++++++++---------------- 1 file changed, 46 insertions(+), 99 deletions(-) diff --git a/seed/challenges/json-apis-and-ajax.json b/seed/challenges/json-apis-and-ajax.json index c522e2441b..1148756772 100644 --- a/seed/challenges/json-apis-and-ajax.json +++ b/seed/challenges/json-apis-and-ajax.json @@ -5,11 +5,10 @@ { "id": "bb000000000000000000001", "title": "Trigger on click Events with jQuery", - "difficulty": 3.19, "description": [ "With jQuery we are able to get data from APIs via Ajax.", - "This data normally comes in the form of JSON.", - "Let's get the Get Message button to set the text of a div.", + "This data normally comes in the form of JSON.", + "Let's get the Get Message button to set the text of a div element.", "We will later use this to display the result of out API request.", "$(\"#getMessage\").on(\"click\", function(){", "  $(\".message\").html(\"Here is the message\");", @@ -33,13 +32,11 @@ "
", "

Cat Photo Finder

", "
", - "
", "
", "
", " The message will go here", "
", "
", - "
", "
", "
", "
\"", "", " });", " ", - " //Don't modify above here", - " ", "     $(\".message\").html(html);", " ", "   });", @@ -248,19 +214,15 @@ " });", "fcces", "", - "", - "", "
", "
", "

Cat Photo Finder

", "
", - "
", "
", "
", " The message will go here", "
", "
", - "
", "
", "
", "
\"", "", " });", " ", - " //Don't modify above here", - " ", "     $(\".message\").html(html);", " ", "   });", @@ -337,19 +293,16 @@ " });", "fcces", "", - "", "", "
", "
", "

Cat Photo Finder

", "
", - "
", "
", "
", " The message will go here", "
", "
", - "
", "
", "
", " " : "upvote") + - "" + + "" + "
" + "
" + "" + "" + "" + "
" + From 6dfda0166191aad737c6d498d5df522f4b8f520b Mon Sep 17 00:00:00 2001 From: Michael Krebs Date: Wed, 21 Oct 2015 17:15:25 -0400 Subject: [PATCH 054/118] Changes Finders Keepers MDN link from array.some() to array.filter() --- seed/challenges/intermediate-bonfires.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/intermediate-bonfires.json b/seed/challenges/intermediate-bonfires.json index d8b008208d..ea05dd355f 100644 --- a/seed/challenges/intermediate-bonfires.json +++ b/seed/challenges/intermediate-bonfires.json @@ -633,7 +633,7 @@ "assert.strictEqual(find([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'message: find([1, 3, 5, 9], function(num) { return num % 2 === 0; }) should return undefined.');" ], "MDNlinks": [ - "Array.some()" + "Array.filter()" ], "type": "bonfire", "challengeType": 5, From 5105efa62492b2e2d56c35e95c21fa871cb4e942 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 21 Oct 2015 15:04:58 -0700 Subject: [PATCH 055/118] add solutions to challenges object and add solutions for upper intermediate bonfires --- common/models/challenge.json | 4 ++++ seed/challenges/upper-intermediate-bonfires.json | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/common/models/challenge.json b/common/models/challenge.json index 84cf3a4c6b..81d6af6eef 100644 --- a/common/models/challenge.json +++ b/common/models/challenge.json @@ -82,6 +82,10 @@ }, "descriptionPt": { "type": "array" + }, + "solutions": { + "type": "array", + "default": [] } }, "validations": [], diff --git a/seed/challenges/upper-intermediate-bonfires.json b/seed/challenges/upper-intermediate-bonfires.json index c09cb30da4..b4ab210cd2 100644 --- a/seed/challenges/upper-intermediate-bonfires.json +++ b/seed/challenges/upper-intermediate-bonfires.json @@ -39,6 +39,9 @@ "Closures", "Details of the Object Model" ], + "solutions": [ + "var Person = function(firstAndLast) {\n\n var firstName, lastName;\n\n function updateName(str) { \n firstName = str.split(\" \")[0];\n lastName = str.split(\" \")[1]; \n }\n\n updateName(firstAndLast);\n\n this.getFirstName = function(){\n return firstName;\n };\n \n this.getLastName = function(){\n return lastName;\n };\n \n this.getFullName = function(){\n return firstName + \" \" + lastName;\n };\n \n this.setFirstName = function(str){\n firstName = str;\n };\n \n\n this.setLastName = function(str){\n lastName = str;\n };\n \n this.setFullName = function(str){\n updateName(str);\n };\n};\n\nvar bob = new Person('Bob Ross');\nbob.getFullName();" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -80,6 +83,9 @@ "MDNlinks": [ "Math.pow()" ], + "solutions": [ + "function orbitalPeriod(arr) {\n var GM = 398600.4418;\n var earthRadius = 6367.4447;\n var TAU = 2 * Math.PI; \n return arr.map(function(obj) {\n return {\n name: obj.name,\n orbitalPeriod: Math.round(TAU * Math.sqrt(Math.pow(obj.avgAlt+earthRadius, 3)/GM))\n };\n });\n}\n\norbitalPeriod([{name : \"sputkin\", avgAlt : 35873.5553}]);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -120,6 +126,9 @@ "Array.reduce()" ], "type": "bonfire", + "solutions": [ + "function pairwise(arr, arg) {\n var sum = 0;\n arr.forEach(function(e, i, a) {\n if (e != null) { \n var diff = arg-e;\n a[i] = null;\n var dix = a.indexOf(diff);\n if (dix !== -1) {\n sum += dix;\n sum += i;\n a[dix] = null;\n } \n }\n });\n return sum;\n}\n\npairwise([1,4,2,3,0,5], 7);\n" + ], "challengeType": 5, "nameCn": "", "descriptionCn": [], From 5077f74ca1d2c8dc9298ab5056a003a9a71afb00 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Wed, 21 Oct 2015 17:42:01 -0700 Subject: [PATCH 056/118] start updating HTML challenge styling --- seed/challenges/html5-and-css.json | 344 +++++++++++++++-------------- server/utils/resources.json | 2 +- 2 files changed, 180 insertions(+), 166 deletions(-) diff --git a/seed/challenges/html5-and-css.json b/seed/challenges/html5-and-css.json index c54d12541a..22f99eb110 100644 --- a/seed/challenges/html5-and-css.json +++ b/seed/challenges/html5-and-css.json @@ -9,7 +9,7 @@ "description": [ "Welcome to Free Code Camp's first coding challenge!", "You can edit code in your text editor, which we've embedded into this web page.", - "Do you see the code in your text editor that says <h1>Hello</h1>? That's an HTML element.", + "Do you see the code in your text editor that says <h1>Hello</h1>? That's an HTML element", "Most HTML elements have an opening tag and a closing tag. Opening tags look like this: <h1>. Closing tags look like this: </h1>. Note that the only difference between opening tags and closing tags is that closing tags have a slash after their opening angle bracket.", "Once you've completed each challenge, and all its tests are passing, the \"Go to my next challenge\" button will become enabled. Click it - or press control and enter at the same time - to advance to the next challenge.", "To enable the \"Go to my next challenge\" button on this exercise, change your h1 tag's text to say \"Hello World\" instead of \"Hello\"." @@ -45,7 +45,7 @@ "Willkommen bei der ersten Programmier-Challenge von Free Code Camp! Klicke auf den folgenden Button für weitere Instruktionen.", "Sehr gut. Jetzt kannst du den Rest der Instruktionen für diese Challenge lesen.", "Mithilfe des eingebauten Text Editors kannst du den Code bearbeiten.", - "Siehst du den Code <h1>Hallo</h1> im Editor? Das ist ein HTML Element.", + "Siehst du den Code <h1>Hallo</h1> im Editor? Das ist ein HTML Element", "Die meisten HTML Elemente haben eine öffnende Auszeichnung (Tag) und eine sich schließende. Öffnende Tags sehen so aus: <h1>. Schließende Tags so: </h1>. Beachte, dass der einzige Unterschied zwischen öffnenden und schließenden Tags in dem Slash besteht, das bei schließenden Tags auf die sich öffnende spitze Klammer folgt.", "Sobald du eine Challenge abgeschlossen hast und alle Tests erfolgreich sind, wird der Button \"Go to my next challenge\" aktiv. Klicke auf diesen – oder drücke Steuerung (Control) und gleichzeitig Enter – um zur nächsten Challenge zu gehen.", "Um den Button \"Go to my next challenge\" dieser Lektion zu aktivieren, ändere den Inhalt des h1 Tags von \"Hello\" zu \"Hello World\"." @@ -57,10 +57,10 @@ "description": [ "Over the next few challenges, we'll build an HTML5 app that will look something like this:", "\"A", - "Add an h2 tag that says \"CatPhotoApp\" to create a second HTML element below your \"Hello World\" h1 element.", "The h2 element you enter will create an h2 element on the website.", "This element tells the browser how to render the text that it contains.", - "h2 elements are slightly smaller than h1 elements. There are also h3, h4, h5 and h6 elements." + "h2 elements are slightly smaller than h1 elements. There are also h3, h4, h5 and h6 elements.", + "Add an h2 tag that says \"CatPhotoApp\" to create a second HTML element below your \"Hello World\" h1 element." ], "tests": [ "assert(($(\"h2\").length > 0), 'Create an h2 element.')", @@ -84,7 +84,7 @@ "Agrega una etiqueta h2 que diga \"CatPhotoApp\" para crear un segundo elemento HTML debajo de tu elemento h1 \"Hello World\".", "El elemento h2 que ingreses creará un elemento h2 en el sitio web.", "Este elemento le dice al navegador cómo mostrar el texto que contiene.", - "Los elementos h2 son ligeramente más pequeños que los elementos h1. También hay elementos h3, h4, h5 y h6." + "Los elementos h2 son ligeramente más pequeños que los elementos h1. También hay elementos h3, h4, h5 y h6" ], "namePt": "", "descriptionPt": [], @@ -100,9 +100,9 @@ "id": "bad87fee1348bd9aedf08801", "title": "Inform with the Paragraph Element", "description": [ - "Create a p element below your h2 element, and give it the text \"Hello Paragraph\".", "p elements are the preferred element for normal-sized paragraph text on websites. P is short for \"paragraph\".", - "You can create a p element like so: <p>I'm a p tag!</p>." + "You can create a p element like so: <p>I'm a p tag!</p>", + "Create a p element below your h2 element, and give it the text \"Hello Paragraph\"." ], "tests": [ "assert(($(\"p\").length > 0), 'Create a p element.')", @@ -123,9 +123,9 @@ "descriptionRu": [], "nameEs": "Waypoint: Informa con el Elemento Párrafo", "descriptionEs": [ - "Crea un elemento párrafo debajo de tu elemento h2, y dale el texto \"Hello Paragraph\". Apenas escribas la etiqueta de apertura <p>, una de nuestras pruebas pasarán (ya que ésta es HTML válido). Asegúrate de cerrar el elemento agregando la etiqueta de cierre </p>.", + "Crea un elemento párrafo debajo de tu elemento h2, y dale el texto \"Hello Paragraph\". Apenas escribas la etiqueta de apertura <p>, una de nuestras pruebas pasarán (ya que ésta es HTML válido). Asegúrate de cerrar el elemento agregando la etiqueta de cierre </p>", "Los elementos párrafo son los principales elementos para los párrafos de texto en tamaño normal en sitios web.", - "Tú puedes crear un elemento párrafo como éste: <p>I'm a p tag!</p>." + "Tú puedes crear un elemento párrafo como éste: <p>I'm a p tag!</p>" ], "namePt": "", "descriptionPt": [], @@ -140,10 +140,10 @@ "id": "bad87fee1348bd9aedf08802", "title": "Uncomment HTML", "description": [ - "Uncomment your h1, h2 and p elements.", "Commenting is a way that you can leave comments within your code without affecting the code itself.", "Commenting is also a convenient way to make code inactive without having to delete it entirely.", - "You can start a comment with <!-- and end a comment with -->." + "You can start a comment with <!-- and end a comment with -->", + "Uncomment your h1, h2 and p elements." ], "tests": [ "assert($(\"h1\").length > 0, 'Make your h1 element visible on your page by uncommenting it.')", @@ -170,10 +170,10 @@ "descriptionRu": [], "nameEs": "Waypoint: Quitar comentarios HTML", "descriptionEs": [ - "Quitar el comentario a los elementos h1, h2 y p.", + "Quitar el comentario a los elementos h1, h2 y p", "Crear comentarios es una forma en la que puedes dejar mensajes dentro de tu código sin afectar el resultado.", "Agregar comentarios es también una forma conveniente de desactivar tu código sin tener que borrarlo por completo.", - "Puedes comenzar un comentario con <!-- y terminar de comentar con -->." + "Puedes comenzar un comentario con <!-- y terminar de comentar con -->" ], "namePt": "", "descriptionPt": [], @@ -189,9 +189,9 @@ "id": "bad87fee1348bd9aedf08804", "title": "Comment out HTML", "description": [ - "Comment out your h1 element and your p element, but leave your h2 element uncommented.", - "Remember that in order to start a comment, you need to use <!-- and to end a comment, you need to use -->.", - "Here you'll need to end the comment before your h2 element begins." + "Remember that in order to start a comment, you need to use <!-- and to end a comment, you need to use -->", + "Here you'll need to end the comment before your h2 element begins.", + "Comment out your h1 element and your p element, but leave your h2 element uncommented." ], "tests": [ "assert(($(\"h1\").length === 0), 'Comment out your h1 element so that it is not visible on your page.')", @@ -218,8 +218,8 @@ "descriptionRu": [], "nameEs": "Waypoint: Comenta en HTML", "descriptionEs": [ - "Comenta el elemento h1 y el elemento p, pero deja sin comentar el elemento h2.", - "Recuerda que para comenzar un comentario, necesitas usar <!-- y para terminar un comentario, necesitas usar -->.", + "Comenta el elemento h1 y el elemento p, pero deja sin comentar el elemento h2", + "Recuerda que para comenzar un comentario, necesitas usar <!-- y para terminar un comentario, necesitas usar -->", "Aquí necesitarás terminar el comentario antes que comience el elemento h2." ], "namePt": "", @@ -237,8 +237,8 @@ "description": [ "Web developers traditionally use lorem ipsum text as placeholder text. It's called lorem ipsum text because those are the first two words of a famous passage by Cicero of Ancient Rome.", "lorem ipsum text has been used as placeholder text by typesetters since the 16th century, and this tradition continues on the web.", - "Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called kitty ipsum text.", - "Replace the text inside your p element with the first few words of this kitty ipsum text: Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff." + "Well, 5 centuries is long enough. Since we're building a CatPhotoApp, let's use something called kitty ipsum text", + "Replace the text inside your p element with the first few words of this kitty ipsum text: Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff." ], "tests": [ "assert.isTrue((/Kitty(\\s)+ipsum(\\s)+dolor/gi).test($(\"p\").text()), 'Your p element should contain the first few words of the provided kitty ipsum text.')" @@ -260,7 +260,7 @@ "descriptionRu": [], "nameEs": "Waypoint: Llena espacios con texto de relleno", "descriptionEs": [ - "Cambia el texto en el elemento p para usar las primeras palabras del texto Kitty Ipsum.", + "Cambia el texto en el elemento p para usar las primeras palabras del texto Kitty Ipsum", "Los desarrolladores web tradicionalmente usan Lorem Ipsum como texto de relleno. Se llama texto Lorem Ipsum porque esas son las primeras dos palabras de una cita famosa de Cicerón de la Roma Antigua.", "El texto Lorem Ipsum ha sido usado como texto de relleno en las imprentas desde el siglo 16, y esta tradición continúa en la web.", "Bueno, 5 siglos es bastante. Ya que estamos construyendo una aplicación de fotos de gatos (CatPhotoApp), ¡usemos algo llamado Kitty Ipsum!", @@ -281,9 +281,9 @@ "id": "bad87fed1348bd9aedf08833", "title": "Delete HTML Elements", "description": [ - "Delete your h1 element so we can simplify our view.", "Our phone doesn't have much vertical space.", - "Let's remove the unnecessary elements so we can start building our CatPhotoApp." + "Let's remove the unnecessary elements so we can start building our CatPhotoApp.", + "Delete your h1 element so we can simplify our view." ], "tests": [ "assert(($(\"h1\").length == 0), 'Delete your h1 element.')", @@ -324,10 +324,11 @@ "id": "bad87fee1348bd9aedf08803", "title": "Change the Color of Text", "description": [ - "Change your h2 element's style so that its text color is red.", - "We can do this by changing the \"style\" of your h2 element.", + "Now let's change the color of some of our text.", + "We can do this by changing the style of your h2 element.", "The style that is responsible for the color of an element's text is the \"color\" style.", - "Here's how you would set your h2 element's text color to blue: <h2 style=\"color: blue\">CatPhotoApp</h2>." + "Here's how you would set your h2 element's text color to blue: <h2 style=\"color: blue\">CatPhotoApp</h2>", + "Change your h2 element's style so that its text color is red." ], "tests": [ "assert($(\"h2\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your h2 element should be red.')" @@ -348,9 +349,9 @@ "nameEs": "Waypoint: Cambia el color del texto", "descriptionEs": [ "Cambia el estilo del elemento h2 de manera que el color de su texto sea rojo.", - "Podemos hacer esto por medio de cambiar el estilo del elemento h2.", + "Podemos hacer esto por medio de cambiar el estilo del elemento h2", "El estilo responsable del color de texto de un elemento es el estilo \"color\".", - "Así es como podrías volver el color de texto de tu elemento h2 en azul: <h2 style=\"color: blue\">CatPhotoApp</h2>." + "Así es como podrías volver el color de texto de tu elemento h2 en azul: <h2 style=\"color: blue\">CatPhotoApp</h2>" ], "namePt": "", "descriptionPt": [], @@ -358,20 +359,23 @@ "descriptionDe": [ "Ändere den Style des h2 Elements, damit die Textfarbe Rot ist.", "Wir können das bewerkstelligen, indem wir den \"style\" des h2 Elements ändern.", - "So könntest du die Textfarbe des h2 Elements in Blau ändern: <h2 style=\"color: blue\">CatPhotoApp</h2>." + "So könntest du die Textfarbe des h2 Elements in Blau ändern: <h2 style=\"color: blue\">CatPhotoApp</h2>" ] }, { "id": "bad87fee1348bd9aedf08805", "title": "Use CSS Selectors to Style Elements", "description": [ - "Delete your h2 element's style attribute and instead create a CSS style element. Add the necessary CSS to turn all h2 elements blue.", "With CSS, there are hundreds of CSS properties that you can use to change the way an element looks on your page.", - "When you entered <h2 style=\"color: red\">CatPhotoApp</h2>, you were giving that individual h2 element an inline style.", - "That's one way to add style to an element, but a better way is by using CSS, which stands for Cascading Style Sheets.", - "At the top of your code, create a style element like this: <style></style>.", - "Inside that style element, you can create a CSS selector for all h2 elements. For example, if you wanted all h2 elements to be red, your style element would look like this: <style>h2 {color: red;}</style>.", - "Note that it's important to have both opening and closing curly braces ({ and }) around each element's style. You also need to make sure your element's style is between the opening and closing style tags. Finally, be sure to add the semicolon to the end of each of your element's styles." + "When you entered <h2 style=\"color: red\">CatPhotoApp</h2>, you were giving that individual h2 element an inline style", + "That's one way to add style to an element, but a better way is by using CSS, which stands for Cascading Style Sheets", + "At the top of your code, create a style element like this: <style></style>", + "Inside that style element, you can create a CSS selector for all h2 elements. For example, if you wanted all h2 elements to be red, your style element would look like this:", + "<style>", + "  h2 {color: red;}", + "</style>", + "Note that it's important to have both opening and closing curly braces ({ and }) around each element's style. You also need to make sure your element's style is between the opening and closing style tags. Finally, be sure to add the semicolon to the end of each of your element's styles.", + "Delete your h2 element's style attribute and instead create a CSS style element. Add the necessary CSS to turn all h2 elements blue." ], "tests": [ "assert(!$(\"h2\").attr(\"style\"), 'Remove the style attribute from your h2 element.')", @@ -396,10 +400,10 @@ "descriptionEs": [ "Borra el atributo style de tu elemento h2 y escribe el CSS para hacer todos los elementos h2 de color azul.", "Con CSS, hay cientos de atributos CSS que puedes usar para cambiar como un elemento se ve en una página web.", - "Cuando entraste <h2 style=\"color: red\">CatPhotoApp<h2>, le estuviste dando a ese elemento h2 en particular un estilo en línea.", - "Esa es una forma de agregar estilo a un elemento, pero una manera mejor es usando Hojas de Estilo en Cascada (Cascading Style Sheets, CSS).", - "Al principio de tu código, crea una etiqueta style como ésta: <style></style>.", - "Dentro de ese elemento style, puedes crear un selector css para todos los elementos h2. Por ejemplo, si querías que todos los elementos h2 sean rojos, tu elemento style se vería así: <style>h2 {color: red;}</style>.", + "Cuando entraste <h2 style=\"color: red\">CatPhotoApp<h2>, le estuviste dando a ese elemento h2 en particular un estilo en línea", + "Esa es una forma de agregar estilo a un elemento, pero una manera mejor es usando Hojas de Estilo en Cascada (Cascading Style Sheets, CSS)", + "Al principio de tu código, crea una etiqueta style como ésta: <style></style>", + "Dentro de ese elemento style, puedes crear un selector css para todos los elementos h2. Por ejemplo, si querías que todos los elementos h2 sean rojos, tu elemento style se vería así: <style>h2 {color: red;}</style>", "Fíjate que es importante tener llaves de apertura y de cierre ({ y }) alrededor del estilo para cada elemento. También necesitas asegurarte que el estilo para tu elemento está entre las etiquetas style de apertura y cierre. Finalmente, asegúrate de agregar el punto y coma al final de cada uno de los estilos de tu elemento." ], "namePt": "", @@ -419,7 +423,6 @@ "id": "bad87fee1348bd9aecf08806", "title": "Use a CSS Class to Style an Element", "description": [ - "Create a CSS class called red-text and apply it to your h2 element.", "Classes are reusable styles that can be added to HTML elements.", "Here's an example CSS class declaration:", "<style>", @@ -428,9 +431,10 @@ "  }", "</style>", "You can see that we've created a CSS class called blue-text within the <style> tag.", - "You can apply a class to an HTML element like this: <h2 class=\"blue-text\">CatPhotoApp</h2>.", + "You can apply a class to an HTML element like this: <h2 class=\"blue-text\">CatPhotoApp</h2>", "Note that in your CSS style element, classes should start with a period. In your HTML elements' class declarations, classes shouldn't start with a period.", - "Instead of creating a new style element, try removing the h2 style declaration from your existing style element, then replace it with the class declaration for .red-text." + "Instead of creating a new style element, try removing the h2 style declaration from your existing style element, then replace it with the class declaration for .red-text", + "Create a CSS class called red-text and apply it to your h2 element." ], "tests": [ "assert($(\"h2\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your h2 element should be red.')", @@ -458,12 +462,12 @@ "descriptionRu": [], "nameEs": "Waypoint: Utiliza una clase CSS para darle estilo a un elemento", "descriptionEs": [ - "Crea una clase CSS llamada \"red-text\" y aplicala a tu elemento h2.", + "Crea una clase CSS llamada \"red-text\" y aplicala a tu elemento h2", "Las clases son estilos reutilizables que pueden ser añadidos a elementos HTML", "Esta es la anatomía de una clase CSS:", "\"a", - "Puedes ver que hemos creado una clase CSS llamada \"blue-text\" dentro de la etiqueta <style>.", - "Puedes aplicar una clase a un elemento HTML de esta manera: <h2 class=\"blue-text\">CatPhotoApp</h2>.", + "Puedes ver que hemos creado una clase CSS llamada \"blue-text\" dentro de la etiqueta <style>", + "Puedes aplicar una clase a un elemento HTML de esta manera: <h2 class=\"blue-text\">CatPhotoApp</h2>", "Nota que en el elemento CSS style, las clases deberían comenzar con un punto. En los elementos HTML, las declaraciones de clase, NO deberían comenzar con punto. ", "En vez de de crear un nuevo elemento style, prueba remover la declaración de estilo de h2 y reemplazarla por la declaración \"red-text\"." ], @@ -476,7 +480,7 @@ "So sieht eine CSS Klasse aus:", "\"Ein", "Du siehst, dass wir die CSS Klasse \"blue-text\" innerhalb von <style> geschrieben haben.", - "Du kannst eine Klasse folgendermaßen einem HTML Element beifügen: <h2 class=\"blue-text\">CatPhotoApp</h2>.", + "Du kannst eine Klasse folgendermaßen einem HTML Element beifügen: <h2 class=\"blue-text\">CatPhotoApp</h2>", "Beachte, dass Klassen in deinem CSS style Element mit einem Punkt beginngen sollten. In deinen Klassen-Deklarationen von HTML Elementen sollten diese nicht mit einem Punkt beginnen.", "Anstatt ein neues style Element zu erstellen, versuche die h2 Style-Deklaration von deinem bereits bestehenden Style Element zu entfernen und sie mit der Klassen-Deklaration \".red-text\" zu ersetzen." ] @@ -485,15 +489,20 @@ "id": "bad87fee1348bd9aefe08806", "title": "Style Multiple Elements with a CSS Class", "description": [ - "Apply the red-text class to your h2 and p elements.", "Remember that you can attach classes to HTML elements by using class=\"your-class-here\" within the relevant element's opening tag.", - "Remember that CSS class selectors require a period at the beginning like this: .blue-text { color: blue; }, but that class declarations don't use a period, like this: <h2 class=\"blue-text\">CatPhotoApp<h2>." + "Remember that CSS class selectors require a period at the beginning like this:", + ".blue-text {", + "  color: blue;", + "}", + "But also remember that class declarations don't use a period, like this:", + "<h2 class=\"blue-text\">CatPhotoApp<h2>", + "Apply the red-text class to your h2 and p elements." ], "tests": [ "assert($(\"h2\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your h2 element should be red.')", - "assert($(\"h2\").hasClass(\"red-text\"), 'Your h2 element should have the class red-text.')", + "assert($(\"h2\").hasClass(\"red-text\"), 'Your h2 element should have the class red-text')", "assert($(\"p\").css(\"color\") === \"rgb(255, 0, 0)\", 'Your p element should be red.')", - "assert($(\"p\").hasClass(\"red-text\"), 'Your p element should have the class red-text.')" + "assert($(\"p\").hasClass(\"red-text\"), 'Your p element should have the class red-text')" ], "challengeSeed": [ "" - ], - "type": "waypoint", - "challengeType": 0, - "nameCn": "", - "descriptionCn": [], - "nameFr": "", - "descriptionFr": [], - "nameRu": "", - "descriptionRu": [], - "nameEs": "", - "descriptionEs": [], - "namePt": "", - "descriptionPt": [], - "nameDe": "", - "descriptionDe": [] } ] } diff --git a/server/utils/resources.json b/server/utils/resources.json index a634575437..c80b9dafa7 100644 --- a/server/utils/resources.json +++ b/server/utils/resources.json @@ -70,7 +70,7 @@ "Ride like the wind!", "Legen - wait for it - dary!", "Ludicrous Speed! Go!", - "Yes you can!", + "Yes we can!", "Most triumphant!", "One loop to rule them all!", "By the power of Grayskull!", From d232e03e01b8535f3c0f5055440121d91a29ae2f Mon Sep 17 00:00:00 2001 From: Michael Krebs Date: Wed, 21 Oct 2015 20:56:14 -0400 Subject: [PATCH 057/118] Adds dting's solutions to advanced bonfires --- seed/challenges/advanced-bonfires.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/seed/challenges/advanced-bonfires.json b/seed/challenges/advanced-bonfires.json index 8ff025e2fe..b68dc4b0ff 100644 --- a/seed/challenges/advanced-bonfires.json +++ b/seed/challenges/advanced-bonfires.json @@ -57,6 +57,9 @@ "MDNlinks": [ "RegExp" ], + "solutions": [ + "var re = /^(?:(?:\\+?1\\s*(?:[.-]\\s*)?)?(?:\\(\\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\\s*\\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\\s*(?:[.-]\\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\\s*(?:[.-]\\s*)?([0-9]{4})$/;\n\nfunction telephoneCheck(str) {\n return !!str.match(re);\n}\n\ntelephoneCheck(\"555-555-5555\");" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -95,6 +98,9 @@ "Array.reduce()", "Symmetric Difference" ], + "solutions": [ + "function sym(args) {\n var index = -1;\n var length = arguments.length;\n var result;\n while (++index < length) {\n var array = arguments[index];\n result = result ? diff(result, array).concat(diff(array, result)) : array;\n }\n return result ? uniq(result) : [];\n}\n\nfunction uniq(arr) {\n var h = Object.create(null);\n var u = [];\n arr.forEach(function(v) {\n if (v in h) return;\n h[v] = true;\n u.push(v);\n });\n return u;\n}\n\nfunction diff(a, b) {\n var h = Object.create(null);\n b.forEach(function(v) {\n h[v] = true; \n });\n return a.filter(function(v) { return !(v in h);});\n}\nsym([1, 2, 3], [5, 2, 1, 4]);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -151,6 +157,9 @@ "MDNlinks": [ "Global Object" ], + "solutions": [ + "var VALUES = [1, 5, 10, 25, 100, 500, 1000, 2000, 10000];\n\nfunction drawer(price, cash, cid) {\n cash = ~~(cash * 100);\n price = ~~(price * 100);\n var diff = cash-price;\n cid.forEach(function(c) {\n c[1] = ~~(c[1] * 100);\n });\n var totalCid = cid.reduce(function(a, c) {\n return a + c[1];\n }, 0);\n if (diff > totalCid) {\n return \"Insufficient Funds\";\n }\n if (diff === totalCid) {\n return \"Closed\";\n }\n \n var change = []; \n var index = cid.length;\n while (diff > 0 && --index > -1) {\n var t = 0;\n var value = VALUES[index];\n while (diff >= value && cid[index][1] > 0) {\n t += value;\n cid[index][1] -= value;\n diff -= value;\n }\n if (t) {\n change.push([cid[index][0], t/100]);\n }\n console.log(JSON.stringify(change));\n }\n // Here is your change, ma'am.\n return change;\n}\n\n// Example cash-in-drawer array:\n// [['PENNY', 1.01],\n// ['NICKEL', 2.05],\n// ['DIME', 3.10],\n// ['QUARTER', 4.25],\n// ['ONE', 90.00],\n// ['FIVE', 55.00],\n// ['TEN', 20.00],\n// ['TWENTY', 60.00],\n// ['ONE HUNDRED', 100.00]]\n\ndrawer(19.50, 20.00, [['PENNY', 1.01], ['NICKEL', 2.05], ['DIME', 3.10], ['QUARTER', 4.25], ['ONE', 90.00], ['FIVE', 55.00], ['TEN', 20.00], ['TWENTY', 60.00], ['ONE HUNDRED', 100.00]]);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -205,6 +214,9 @@ "MDNlinks": [ "Global Array Object" ], + "solutions": [ + "function inventory(arr1, arr2) {\n arr2.forEach(function(item) {\n createOrUpdate(arr1, item);\n });\n // All inventory must be accounted for or you're fired!\n return arr1;\n}\n\nfunction createOrUpdate(arr1, item) {\n var index = -1;\n while (++index < arr1.length) {\n if (arr1[index][1] === item[1]) {\n arr1[index][0] += item[0];\n return;\n }\n if (arr1[index][1] > item[1]) {\n break;\n }\n }\n arr1.splice(index, 0, item);\n}\n\n// Example inventory lists\nvar curInv = [\n [21, 'Bowling Ball'],\n [2, 'Dirty Sock'],\n [1, 'Hair Pin'],\n [5, 'Microphone']\n];\n\nvar newInv = [\n [2, 'Hair Pin'],\n [3, 'Half-Eaten Apple'],\n [67, 'Bowling Ball'],\n [7, 'Toothpaste']\n];\n\ninventory(curInv, newInv);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -246,6 +258,9 @@ "Permutations", "RegExp" ], + "solutions": [ + "function permAlone(str) {\n return permutor(str).filter(function(perm) {\n return !perm.match(/(.)\\1/g);\n }).length;\n}\n\nfunction permutor(str) {\n // http://staff.roguecc.edu/JMiller/JavaScript/permute.html\n //permArr: Global array which holds the list of permutations\n //usedChars: Global utility array which holds a list of \"currently-in-use\" characters\n var permArr = [], usedChars = [];\n function permute(input) {\n //convert input into a char array (one element for each character)\n var i, ch, chars = input.split(\"\");\n for (i = 0; i < chars.length; i++) {\n //get and remove character at index \"i\" from char array\n ch = chars.splice(i, 1);\n //add removed character to the end of used characters\n usedChars.push(ch);\n //when there are no more characters left in char array to add, add used chars to list of permutations\n if (chars.length === 0) permArr[permArr.length] = usedChars.join(\"\");\n //send characters (minus the removed one from above) from char array to be permuted\n permute(chars.join(\"\"));\n //add removed character back into char array in original position\n chars.splice(i, 0, ch);\n //remove the last character used off the end of used characters array\n usedChars.pop();\n }\n }\n permute(str);\n return permArr;\n}\n\npermAlone('aab');\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", @@ -291,6 +306,9 @@ "String.substr()", "parseInt()" ], + "solutions": [ + "function friendly(str) {\n var dates = str.map(function(s) {return s.split('-').map(Number);});\n var start = dates[0];\n var end = dates[1];\n if (str[0] === str[1]) {\n return [readable(start)];\n }\n if (start[0] !== end[0]) {\n if (start[0] + 1 === end[0] && start[1] > end[1]) {\n start[0] = undefined;\n end[0] = undefined;\n }\n return dates.map(readable);\n }\n start[0] = undefined;\n end[0] = undefined;\n if (start[1] !== end[1]) {\n return dates.map(readable);\n }\n end[1] = undefined;\n return dates.map(readable);\n}\n\nfunction readable(arr) {\n var ordD = arr[2] + nth(arr[2]);\n if (!arr[1]) {\n return ordD;\n }\n return MONTH[arr[1]] + \" \" + ordD + (!arr[0] ? \"\" : \", \" + arr[0]);\n}\n\nvar MONTH = {1: \"January\",\n 2: \"February\",\n 3: \"March\",\n 4: \"April\",\n 5: \"May\",\n 6: \"June\",\n 7: \"July\",\n 8: \"August\",\n 9: \"September\",\n 10: \"October\",\n 11: \"November\",\n 12: \"December\"};\n\nfunction nth(d) {\n if(d>3 && d<21) return 'th';\n switch (d % 10) {\n case 1: return \"st\";\n case 2: return \"nd\";\n case 3: return \"rd\";\n default: return \"th\";\n }\n} \n\nfriendly(['2015-07-01', '2015-07-04']);\n" + ], "type": "bonfire", "challengeType": 5, "nameCn": "", From 2e2990770e3b839157e64007ea8e56e5d0af6b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Veras?= Date: Wed, 21 Oct 2015 23:49:17 -0400 Subject: [PATCH 058/118] Updating the waypoint information After commit ec1d3ac in learnyoumongo, exercise "Find Limit" was renamed to "Find Project". --- seed/challenges/mongodb.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/mongodb.json b/seed/challenges/mongodb.json index 0fe93ba6f9..facfb56089 100644 --- a/seed/challenges/mongodb.json +++ b/seed/challenges/mongodb.json @@ -25,7 +25,7 @@ "Complete \"Mongod\"", "Complete \"Connect\"", "Complete \"Find\"", - "Complete \"Find Limit\"", + "Complete \"Find Project\"", "Complete \"Insert\"", "Complete \"Update\"", "Complete \"Remove\"", From 5ee8b50431ad7de36d09f94f51bcfa18649bcb49 Mon Sep 17 00:00:00 2001 From: junhaoyap Date: Wed, 21 Oct 2015 21:02:43 -0700 Subject: [PATCH 059/118] Make first jQuery lesson more lenient for script tag --- seed/challenges/jquery.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/seed/challenges/jquery.json b/seed/challenges/jquery.json index d4625a85a4..bff88bccfc 100644 --- a/seed/challenges/jquery.json +++ b/seed/challenges/jquery.json @@ -16,8 +16,7 @@ "This is important because without your document ready function, your code may run before your HTML is rendered, which would cause bugs." ], "tests": [ - "assert(editor.match(/