fix(curriculum): change debugging console lesson (#38554)
* changed lesson to match behaviour * Update wording for debugging Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * Update wording from suggestion Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * all suggestions with note * fix: replaced code tags with backticks for markdown Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Ashraf Nazar <ashraf.caspian@gmail.com> Co-Authored-By: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
@ -9,15 +9,17 @@ forumTopicId: 301193
|
||||
<section id='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.
|
||||
The following challenge is meant to highlight the main difference between the freeCodeCamp console and your browser console.
|
||||
When you run ordinary JavaScript, the browsers console will display your <code>console.log()</code> statements the exact number of times you requested.
|
||||
The freeCodeCamp console will print your <code>console.log()</code> statements for each test of that challenge, as well as one more time for any function calls that you have in your code.
|
||||
This lends itself to some interesting behavior and might trip you up in the beginning, because a logged value that you expect to see only once may print out many more times.
|
||||
If you would like to see only your single output and not have to worry about running through the test cycles, you can use <code>console.clear()</code> and check the browsers console.
|
||||
When you run ordinary JavaScript, the browser's console will display your <code>console.log()</code> statements the exact number of times it is called.
|
||||
The freeCodeCamp console will print your <code>console.log()</code> 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 <code>console.clear()</code> before any other <code>console</code> 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.
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id='instructions'>
|
||||
First, use <code>console.clear()</code> to clear the browser console. After that, use <code>console.log</code> to log the <code>output</code> variable.
|
||||
First, use <code>console.log</code> to log the <code>output</code> variable. Then, use <code>console.clear</code> to clear the browser console.
|
||||
</section>
|
||||
|
||||
## Tests
|
||||
@ -41,14 +43,12 @@ tests:
|
||||
|
||||
```js
|
||||
// Open your browser console.
|
||||
let output = "Get this to log once in the browser console and twice in the freeCodeCamp console";
|
||||
// Use console.clear() on the next line to clear the 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.
|
||||
|
||||
// Run the tests to see the difference between the two consoles.
|
||||
|
||||
// Check the two consoles to see the difference. The freeCodeCamp console should have printed the variable twice, once for each test of this challenge. The browser console should only print the variable once because you cleared it first.
|
||||
// Now, add console.clear() before your console.log() to clear the browser console, and pass the tests.
|
||||
```
|
||||
|
||||
</div>
|
||||
@ -63,14 +63,14 @@ let output = "Get this to log once in the browser console and twice in the freeC
|
||||
|
||||
```js
|
||||
// Open your browser console.
|
||||
let output = "Get this to log once in the browser console and twice in the freeCodeCamp console";
|
||||
// Use console.clear() on the next line to clear the browser console.
|
||||
console.clear();
|
||||
|
||||
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();
|
||||
console.log(output);
|
||||
|
||||
// Check the two consoles to see the difference. The freeCodeCamp console should have printed the variable twice, one for each test of this challenge. The browser console should only print the variable once because you cleared it first.
|
||||
// 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.
|
||||
```
|
||||
|
||||
</section>
|
||||
|
Reference in New Issue
Block a user