How do i use console.clear to modify

Tell us what’s happening:

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
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(outputOne)

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/debugging/understanding-the-differences-between-the-freecodecamp-and-browser-console

console.clear does not take arguments.

console.clear() definitely isn’t what you’re looking for.

There are some potential HACKY ways to do what you want, depending on why you want it.

For example, you can create your own logging function. Then the browser will display the same message that is logged out consecutively as a single message with a count indicator.

But, it’s important to note that this will mean your line numbers are coming from the log function, instead of your original log location.

I would absolutely advise you against doing this in most cases! But there may be cases where this could be useful. So, if you use it, do so with caution!

const log = (...params) => console.log(...params);

// Open your browser console
let outputTwo = "This will print to the browser console 2 times";
// Use console.log() to print the outputTwo variable
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
log(outputOne)

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

outputs …