Hi. This seems quite simple, but I’m not understanding what this is supposed to do? Technically I solved the challenge, but nothing logged to the FCC console OR my browser console more than once. I’d just like to know if there’s a different way I’m supposed to be running this.
I’m on chrome, btw.
// 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);
It’s very difficult to write efficient JavaScript code without debugging. You must diagnose into code to find an actual root cause.
In the era of IE, most of the programmer debug using alert. But now a day’s many methods and tools added into browsers. Especially with firebug and chrome dev tools, lots of methods have been introduced.
Alert
Alert method is used from beginning of JavaScript development. It displays a value of string or variable into an alert box. Not much useful currently as more advanced methods available. It’s annoying to get a dialog on the page every time when line getting executes.
Syntax: alert(‘Hi’)
Console
Currently, Most of the developer used this method to debug. Console API has multiple methods to debug JavaScript code. Most useful is console.log that log this parameter on the console of a developer tool.
Various methods of console API: assert,clear,count,debug,dir,dirxml,error,group,groupCollapsed,groupEnd,info,log,profile,profileEnd,time,timeEnd,timeStamp,trace,warn