From cfbc7e9283b211014dba650f4237215b2138f43e Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Fri, 27 Aug 2021 10:57:08 -0500 Subject: [PATCH] fix(curriculum): console not repsonding properly issue (#43053) * fix(curriculum): console not repsonding properly issue * fix: refine instructions * fix: add a test + reword to remove seed comments * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md Co-authored-by: Shaun Hamilton * Update curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md Co-authored-by: Shaun Hamilton * fix: remove comments from dictionary * fix: remove comments from i18n dictionaries * Revert "fix: remove comments from dictionary" This reverts commit 7f76d5a8ec6fc5eb29284d408a02341b87ebb084. * Revert "fix: remove comments from i18n dictionaries" This reverts commit 54b1c12cfc88061273f024f682c968a2c660880b. Co-authored-by: Shaun Hamilton --- ...en-the-freecodecamp-and-browser-console.md | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md index b3ec6b24bc..cb849f0678 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console.md @@ -8,26 +8,24 @@ dashedName: understanding-the-differences-between-the-freecodecamp-and-browser-c # --description-- -You may have noticed that some freeCodeCamp JavaScript challenges include their own console. This console behaves a little differently than the browser console you used in the last challenge. +You may have noticed that some freeCodeCamp challenges include their own console. This console behaves a little differently than the browser console. -The following challenge is meant to highlight the main difference between the freeCodeCamp console and your browser console. - -When you run ordinary JavaScript, the browser's console will display your `console.log()` statements the exact number of times it is called. - -The freeCodeCamp console will print your `console.log()` statements a short time after the editor detects a change in the script, as well as during testing. - -The freeCodeCamp console is cleared before the tests are run and, to avoid spam, only prints the logs during the first test (see the note below for exceptions). - -If you would like to see every log for every test, run the tests, and open the browser console. If you prefer to use the browser console, and want it to mimic the freeCodeCamp console, place `console.clear()` before any other `console` calls, to clear the browser console. - -**Note:** `console.log`s inside functions are printed to the freeCodeCamp console whenever those functions are called. This can help debugging functions that are called during testing. +There are many methods to use with `console` to output messages. `log`, `warn`, and `clear` to name a few. The freeCodeCamp console will only output `log` messages, while the browser console will output all messages. When you make changes to your code, it will automatically run and show the logs. The freeCodeCamp console is then cleared each time your code runs. # --instructions-- -First, use `console.log` to log the `output` variable. Then, use `console.clear` to clear the browser console. +First, open your browser console so you can see the logs. To do that, you can right-click the freeCodeCamp navigation bar at the top and click `inspect` on most browsers. Then find the `console` tab in the window that opens. + +After that, use `console.log` to log the `output` variable. View the two consoles to see the log. Finally, use `console.clear` after your log to clear the browser console. View the difference in the two consoles. # --hints-- +You should use `console.log()` to print the `output` variable. + +```js +assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +``` + You should use `console.clear()` to clear the browser console. ```js @@ -38,10 +36,14 @@ assert( ); ``` -You should use `console.log()` to print the `output` variable. +You should clear the console after your log. ```js -assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); +assert( + __helpers + .removeWhiteSpace(code) + .match(/console\.log\(output\)[\s\S]*console.clear\(\)/) +); ``` # --seed-- @@ -49,25 +51,15 @@ assert(__helpers.removeWhiteSpace(code).match(/console\.log\(output\)/)); ## --seed-contents-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. ``` # --solutions-- ```js -// Open your browser console. -let output = "Get this to log once in the freeCodeCamp console and twice in the browser console"; -// Use console.log() to print the output variable. -console.clear(); +let output = "Get this to show once in the freeCodeCamp console and not at all in the browser console"; + console.log(output); - -// Run the tests to see the difference between the two consoles. - -// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests. +console.clear(); ```