Fixed 'Write Reusable JavaScript with Functions' head and tail
This commit is contained in:
@ -2041,19 +2041,7 @@
|
|||||||
"<h4>Instructions</h4>",
|
"<h4>Instructions</h4>",
|
||||||
"<ol><li>Create a function called <code>reusableFunction</code> which prints <code>\"Hi World\"</code> to the dev console.</li><li>Call the function.</li></ol>"
|
"<ol><li>Create a function called <code>reusableFunction</code> which prints <code>\"Hi World\"</code> to the dev console.</li><li>Call the function.</li></ol>"
|
||||||
],
|
],
|
||||||
"challengeSeed": [
|
"head": [
|
||||||
"// Example",
|
|
||||||
"function reusableFunction() {",
|
|
||||||
" console.log(\"Heyya, World\");",
|
|
||||||
"}",
|
|
||||||
"",
|
|
||||||
"reusableFunction();",
|
|
||||||
"",
|
|
||||||
"// Only change code below this line",
|
|
||||||
"",
|
|
||||||
""
|
|
||||||
],
|
|
||||||
"tail": [
|
|
||||||
"var logOutput = \"\";",
|
"var logOutput = \"\";",
|
||||||
"var originalConsole = console",
|
"var originalConsole = console",
|
||||||
"function capture() {",
|
"function capture() {",
|
||||||
@ -2073,12 +2061,26 @@
|
|||||||
" console.log = originalConsole.log;",
|
" console.log = originalConsole.log;",
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
|
"capture();"
|
||||||
|
],
|
||||||
|
"challengeSeed": [
|
||||||
|
"// Example",
|
||||||
|
"function reusableFunction() {",
|
||||||
|
" console.log(\"Heyya, World\");",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"reusableFunction();",
|
||||||
|
"",
|
||||||
|
"// Only change code below this line",
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"tail": [
|
||||||
|
"uncapture();",
|
||||||
|
"",
|
||||||
"if (typeof reusableFunction !== \"function\") { ",
|
"if (typeof reusableFunction !== \"function\") { ",
|
||||||
" (function() { return \"reusableFunction is not defined\"; })();",
|
" (function() { return \"reusableFunction is not defined\"; })();",
|
||||||
"} else {",
|
"} else {",
|
||||||
" capture();",
|
|
||||||
" reusableFunction(); ",
|
|
||||||
" uncapture();",
|
|
||||||
" (function() { return logOutput || \"console.log never called\"; })();",
|
" (function() { return logOutput || \"console.log never called\"; })();",
|
||||||
"}"
|
"}"
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user