Merge pull request #7856 from erictleung/fix/usability-on-local-scope-and-functions
Clarify instructions for Local Scope and Functions
This commit is contained in:
@ -2262,23 +2262,24 @@
|
|||||||
"<blockquote>function myTest() {<br> var loc = \"foo\";<br> console.log(loc);<br>}<br>myTest(); // \"foo\"<br>console.log(loc); // \"undefined\"</blockquote>",
|
"<blockquote>function myTest() {<br> var loc = \"foo\";<br> console.log(loc);<br>}<br>myTest(); // \"foo\"<br>console.log(loc); // \"undefined\"</blockquote>",
|
||||||
"<code>loc</code> is not defined outside of the function.",
|
"<code>loc</code> is not defined outside of the function.",
|
||||||
"<h4>Instructions</h4>",
|
"<h4>Instructions</h4>",
|
||||||
"Declare a local variable <code>myVar</code> inside <code>myFunction</code>"
|
"Declare a local variable <code>myVar</code> inside <code>myFunction</code>. Run the tests and then follow the instructions commented out in the editor.",
|
||||||
|
"<strong>Hint</strong><br>Refreshing the page may help if you get stuck."
|
||||||
],
|
],
|
||||||
"releasedOn": "January 1, 2016",
|
"releasedOn": "January 1, 2016",
|
||||||
"head": [
|
"head": [
|
||||||
"var logOutput = \"\";",
|
"var logOutput = \"\";",
|
||||||
"var originalConsole = console",
|
"var originalConsole = console",
|
||||||
"function capture() {",
|
"function capture() {",
|
||||||
" var nativeLog = console.log;",
|
" var nativeLog = console.log;",
|
||||||
" console.log = function (message) {",
|
" console.log = function (message) {",
|
||||||
" logOutput = message;",
|
" logOutput = message;",
|
||||||
" if(nativeLog.apply) {",
|
" if(nativeLog.apply) {",
|
||||||
" nativeLog.apply(originalConsole, arguments);",
|
" nativeLog.apply(originalConsole, arguments);",
|
||||||
" } else {",
|
" } else {",
|
||||||
" var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');",
|
" var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');",
|
||||||
" nativeLog(nativeMsg);",
|
" nativeLog(nativeMsg);",
|
||||||
" }",
|
" }",
|
||||||
" };",
|
" };",
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
"function uncapture() {",
|
"function uncapture() {",
|
||||||
@ -2295,11 +2296,11 @@
|
|||||||
"}",
|
"}",
|
||||||
"myFunction();",
|
"myFunction();",
|
||||||
"",
|
"",
|
||||||
"// run and check the console ",
|
"// Run and check the console",
|
||||||
"// myVar is not defined outside of myFunction",
|
"// myVar is not defined outside of myFunction",
|
||||||
"console.log(myVar);",
|
"console.log(myVar);",
|
||||||
"",
|
"",
|
||||||
"// now remove the console log line to pass the test",
|
"// Now remove the console log line to pass the test",
|
||||||
""
|
""
|
||||||
],
|
],
|
||||||
"tail": [
|
"tail": [
|
||||||
|
Reference in New Issue
Block a user