title: jQuery - How do I simplify code that performs similar, but slightly different functions?
body: <p>I have several lines of code that perform similar functions (they take the values from inputs and appends a line of code). Is there a way that I could simplify these?</p>
  
  <pre><code>    //======Name
          var name = $('input[name=Name]').val();
          if (name){
          $('.results').append('&lt;div class="item"&gt;' + '&lt;p&gt;Your name is ' + name + '.&lt;/p&gt;' + '&lt;/div&gt;');}
  //======Age
          var age = $('input[name=YourAge]:checked').val();
          if (age){
          $('.results').append('&lt;div class="item"&gt;' + '&lt;p&gt;Your age is ' + age + '.&lt;/p&gt;' + '&lt;/div&gt;');}
  //======Occupation
          var occupation = $('input[name=Occupation]').val();
          if(occupation){
          $('.results').append('&lt;div class="item"&gt;' + '&lt;p&gt;Your occupation is ' + occupation + '.&lt;/p&gt;' + '&lt;/div&gt;');}
  </code></pre>