Clarify instructions for Local Scope and Functions
- Add additional instructions on following commented out instructions - Add hint to refresh page if you encounter issues - Lint the head script to follow two space indent - Capitalize words in commented out instructionspull/7856/head
parent
763aaeb6d1
commit
35e38d61b8
|
@ -2264,23 +2264,24 @@
|
|||
"<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.",
|
||||
"<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",
|
||||
"head": [
|
||||
"var logOutput = \"\";",
|
||||
"var originalConsole = console",
|
||||
"function capture() {",
|
||||
" var nativeLog = console.log;",
|
||||
" console.log = function (message) {",
|
||||
" logOutput = message;",
|
||||
" if(nativeLog.apply) {",
|
||||
" nativeLog.apply(originalConsole, arguments);",
|
||||
" } else {",
|
||||
" var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');",
|
||||
" nativeLog(nativeMsg);",
|
||||
" }",
|
||||
" };",
|
||||
" var nativeLog = console.log;",
|
||||
" console.log = function (message) {",
|
||||
" logOutput = message;",
|
||||
" if(nativeLog.apply) {",
|
||||
" nativeLog.apply(originalConsole, arguments);",
|
||||
" } else {",
|
||||
" var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');",
|
||||
" nativeLog(nativeMsg);",
|
||||
" }",
|
||||
" };",
|
||||
"}",
|
||||
"",
|
||||
"function uncapture() {",
|
||||
|
@ -2297,11 +2298,11 @@
|
|||
"}",
|
||||
"myFunction();",
|
||||
"",
|
||||
"// run and check the console ",
|
||||
"// Run and check the console",
|
||||
"// myVar is not defined outside of myFunction",
|
||||
"console.log(myVar);",
|
||||
"",
|
||||
"// now remove the console log line to pass the test",
|
||||
"// Now remove the console log line to pass the test",
|
||||
""
|
||||
],
|
||||
"tail": [
|
||||
|
|
Loading…
Reference in New Issue