Understanding the Differences between the freeCodeCamp and Browser Console 5

Tell us what’s happening:
I’m confused as to how to complete this code as I’ve never done something for JavaScript that requires debugging. How do I complete this challenge?

Your code so far

// Open your browser console
let outputTwo = "This will print to the browser console 2 times";
// Use console.log() to print the outputTwo variable

let outputOne = "Try to get this to log only once to the browser console";
// Use console.clear() in the next line to print the outputOne only once

// Use console.log() to print the outputOne variable

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36 Avast/72.0.1174.122.

Link to the challenge:

1 Like

The challenge is worded a little confusingly.

Your browser has an inbuilt console for logging. In Chrome on Windows/Linux, you can view it by pressing Ctrl + Shift + J.

Any call to console.log(myVar) outputs the value of myVar to the console. Calling console.clear() clears everything previously output to the console.

If your fCC code contains calls to console.log(), they will be run every time that bit of code runs, so you may see multiple log outputs for a single call, because the fCC test suite often runs your functions many times with different inputs to check that they work correctly.

To pass this challenge, you just need to log the two variables and clear the console.

How exactly do I do that? I’ve been confused by this so much this morning, that my brain is hurting.

What is it that you are asking about? What parts of the explanation you don’t understand? What is “that”?

I figured it out, somehow. My brain just isn’t working today, and I’m not sure why. I’m doing all of this to prepare for my two new courses in school starting Monday, and I’m just about prepared, yet I’m not fully prepared at all. I’m just having an off day, and picked a bad day to start coding again, it seems.

Don’t worry, it happens to the best of us. Everyone has bad and good days.

The specifics of this challenge aren’t so important conceptually, as they only apply to other fCC challenges.

The important takeaway is that your browser has a console, accessible through the console object, which has useful methods such as log and clear.

In fact, the console is useful for more things than just debugging. You can also use it as a REPL (a place to immediately run code). Try typing:


into the console while you’re still on this forum, and you should see the header disappear — you’ll need to refresh the page to get it back.

1 Like

I actually was able to figure that one out, surprisingly. I just ignored the console.clear() and next thing I know, I got it right.