Learn about console.assert, which is syntactic sugar for logging an error the console when a given condition is not met. It's useful, but may not do what you expect if you're coming from another language - watch this lesson to learn how to use it, and when not to.
BTW, console.assert is very useful if you're doing a quick TDD when you're writing on JSBIN or something like that. So you might want to do something like:
myFn(){
}
console.assert(myFn(3) === 3);
console.assert(myFn(6) === 3);
console.info("All tests passed");
then implement the function so that there are no errors in console and then finally delete the console calls.