How to log with return statement


Hey guys just wanted to know how I would log my code to the console using a return statement. Specifically the "return true" part of my function. Anyone have any ideas in mind?

var tired = true;
var bored = false;

function nap() {
  if (tired || bored) {
      return true;
  } else {
      return false;



You could simply place your function call inside your console.log parentheses. i.e.

console.log( "Take a nap? " + nap() ); //Prints "Take a nap? true/false"

Or you could first assign the return result to a new variable then place that variable in your console.log statement. i.e.

var result = nap();

console.log( "Take a nap? " + result ); //Will also print "Take a nap? true/false"


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.