Understanding the Differences between the freeCodeCamp and Browser Console

I’ve been trying his problem for a quite long time now. I’m getting “invalid regexp group”. Can anyone give me a hint? Should this be happening?


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

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
console.clear();

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

Link to the challenge:

2 Likes

I can’t reproduce that error. Are you by any chance using Edge or Safari?

Bugs should always be reported as GitHub Issues. Whenever reporting a bug, please check first that there isn’t already an issue for it and provide as much detail as possible.

1 Like

Same problem here… :wink:

There is an issue here regarding this problem.

4 Likes

I think I found the solution…
Write the code that you wrote there but do not use semi-colons.

1 Like

What is the reason for “printing it out twice”?!
and why do you have to define an argument for console log, but not for console clear?! and how are you supposed to know that console clear doesn’t need an argument? Another terribly explained exercise…

3 Likes

Because when the run the tests it prints out for each test. You’ll have some lessons where it prints more times.

3 Likes

Mine got hung up on having the comment on the same line as the semicolon.

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


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


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

solution
console.clear();
console.log(outputOne);

console.log(outputTwo);
console.clear(); //don’t say console.clear(outputOne).
console.log(outputOne);
//thank you

Actually, no, console.clear() doesn’t use an argument