title: How can I use jasmine.js to test for console output?
body: <p>I'm working through the text: <strong>Professional JavaScript for Web Developers by Nicholas Zakas</strong>
  and I'm testing the examples with Jasmine.js.</p>
  
  <p>I can currently test the output of a function by specifying a return a value, but I'm running into trouble when there are multiple pieces of data that I want to return.</p>
  
  <p>The textbook uses the alert() method, but this is cumbersome and I don't know how to test for alerts. I was wondering if there was a way to test for console.log() output. For instance:</p>
  
  <pre><code>function_to_test = function(){
      var person = new Object();
      person.name = "Nicholas";
      person.age = 29;
  
      return(person.name);    //Nicholas
      return(person.age);     //29
  });
  </code></pre>
  
  <p>I know I can have them return as one string, but for more complicated examples I'd like to be able to test the following:</p>
  
  <pre><code>function_to_test = function(){
      var person = new Object();
      person.name = "Nicholas";
      person.age = 29;
  
      console.log(person.name);    //Nicholas
      console.log(person.age);     //29
  });
  </code></pre>
  
  <p>The Jasmine test looks something like:</p>
  
  <pre><code>it("should test for the function_to_test's console output", function(){
      expect(function_to_test()).toEqual("console_output_Im_testing_for");
  });
  </code></pre>
  
  <p>Is there a simple way to do this that I'm just missing? I'm pretty new to coding so any guidance would be appreciated.</p>