From 96e071687be1805f9a4bc04a0786747e4e763d24 Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 13 Sep 2015 14:04:52 -0400 Subject: [PATCH 1/3] Modify sample function in code to match form of sample function in description --- 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 242d633459..ebbe234111 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -681,7 +681,7 @@ "var a = 4;", "var b = 5;", "", - "ourFunction = function() {", + "function ourFunction(a, b) {", " return a - b;", "};", "", From bf08c300be42ab224f9561342829364e03639133 Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 13 Sep 2015 15:34:54 -0400 Subject: [PATCH 2/3] Remove unneeded tests --- 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 ebbe234111..b731a35a1d 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -675,7 +675,7 @@ "Create and call a function called myFunction that returns the sum of a and b." ], "tests":[ - "assert((function(){if(typeof(f) !== \"undefined\" && typeof(f) === \"number\" && f === a + b && editor.getValue().match(/return/gi).length >= 1 && editor.getValue().match(/a/gi).length >= 1 && editor.getValue().match(/b/gi).length >= 1 && editor.getValue().match(/\\+/gi).length >= 1){return true;}else{return false;}})(), 'Your function should return the value of a + b');" + "assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'Your function should return the value of a + b');" ], "challengeSeed":[ "var a = 4;", From c0f08b140aa5615170e6d904a3d2045647ec4f67 Mon Sep 17 00:00:00 2001 From: Joel Bentley Date: Sun, 13 Sep 2015 16:02:25 -0400 Subject: [PATCH 3/3] Add explanation of how values passed to function --- seed/challenges/basic-javascript.json | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index b731a35a1d..1427597e97 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -666,13 +666,15 @@ "title": "Write Reusable JavaScript with Functions", "difficulty":"9.9819", "description":[ - "In JavaScript, we can divide up our code into reusable parts called functions.", + "In JavaScript, we can divide up our code into reusable parts called functions.", "Here's an example of a function:", - "function functionName (a, b) {", + "function functionName(a, b) {", "  return a + b;", "}", - "We can \"call\" our function like this: functionName();, and it will run and return its return value to us.", - "Create and call a function called myFunction that returns the sum of a and b." + "After writing the above lines in our code, we can then pass values to our function and the result following the return statement will be returned.", + "For example, we can pass numbers 4 and 2 by “calling” the function later in our code like this: functionName(4, 2).", + "In this example, the function will return the number 6 as this is the result of 4 + 2.", + "Create and call a function called myFunction that returns the sum of a and b." ], "tests":[ "assert((function(){if(typeof(f) !== \"undefined\" && f === a + b){return true;}else{return false;}})(), 'Your function should return the value of a + b');"