Fixed 'Write Reusable JavaScript with Functions' head and tail
parent
c4579427fe
commit
84613ac864
|
@ -2041,19 +2041,7 @@
|
|||
"<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>"
|
||||
],
|
||||
"challengeSeed": [
|
||||
"// Example",
|
||||
"function reusableFunction() {",
|
||||
" console.log(\"Heyya, World\");",
|
||||
"}",
|
||||
"",
|
||||
"reusableFunction();",
|
||||
"",
|
||||
"// Only change code below this line",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"tail": [
|
||||
"head": [
|
||||
"var logOutput = \"\";",
|
||||
"var originalConsole = console",
|
||||
"function capture() {",
|
||||
|
@ -2073,12 +2061,26 @@
|
|||
" 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\") { ",
|
||||
" (function() { return \"reusableFunction is not defined\"; })();",
|
||||
"} else {",
|
||||
" capture();",
|
||||
" reusableFunction(); ",
|
||||
" uncapture();",
|
||||
" (function() { return logOutput || \"console.log never called\"; })();",
|
||||
"}"
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue