Merge pull request #3287 from joel-bentley/joel-bentley-1936
Fix confusing Waypoint: Write Reusable JavaScript with Functions
This commit is contained in:
@ -666,22 +666,24 @@
|
|||||||
"title": "Write Reusable JavaScript with Functions",
|
"title": "Write Reusable JavaScript with Functions",
|
||||||
"difficulty":"9.9819",
|
"difficulty":"9.9819",
|
||||||
"description":[
|
"description":[
|
||||||
"In JavaScript, we can divide up our code into reusable parts called <code>functions</code>.",
|
"In JavaScript, we can divide up our code into reusable parts called functions.",
|
||||||
"Here's an example of a function:",
|
"Here's an example of a function:",
|
||||||
"<code>function functionName(a, b) {</code>",
|
"<code>function functionName(a, b) {</code>",
|
||||||
"<code>  return a + b;</code>",
|
"<code>  return a + b;</code>",
|
||||||
"<code>}</code>",
|
"<code>}</code>",
|
||||||
"We can \"call\" our function like this: <code>functionName();</code>, and it will run and return its <code>return</code> value to us.",
|
"After writing the above lines in our code, we can then pass values to our function and the result following the <code>return</code> statement will be returned.",
|
||||||
"Create and call a function called <code>myFunction</code> that returns the sum of a and b."
|
"For example, we can pass numbers <code>4</code> and <code>2</code> by “calling” the function later in our code like this: <code>functionName(4, 2)</code>.",
|
||||||
|
"In this example, the function will return the number <code>6</code> as this is the result of <code>4 + 2</code>.",
|
||||||
|
"Create and call a function called <code>myFunction</code> that returns the sum of <code>a</code> and <code>b</code>."
|
||||||
],
|
],
|
||||||
"tests":[
|
"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":[
|
"challengeSeed":[
|
||||||
"var a = 4;",
|
"var a = 4;",
|
||||||
"var b = 5;",
|
"var b = 5;",
|
||||||
"",
|
"",
|
||||||
"ourFunction = function() {",
|
"function ourFunction(a, b) {",
|
||||||
" return a - b;",
|
" return a - b;",
|
||||||
"};",
|
"};",
|
||||||
"",
|
"",
|
||||||
|
Reference in New Issue
Block a user