/* global SW:true */  

var getUnassigned = function (assignmentCount) {
  var ticketTotal = 0;
  for (var property in assignmentCount) {
    ticketTotal += assignmentCount[property];
  }
  var unassignedTickets = data.tickets.length - ticketTotal;
  console.log('unassignedTickets');
  return unassignedTickets;
}

var countAssignments = function(ticket){
  if (assignmentCount[ticket.assignee.id]){
    assignmentCount[ticket.assignee.id] += 1;
  } else {
    assignmentCount[ticket.assignee.id] = 1;
  }
};

$(document).ready(function(){
  'use strict';
  console.log( 'Doing SW things!' );
  var card = new SW.Card();
  var helpdesk = card.services('helpdesk');
  var assignmentCount = {};
  helpdesk.request('tickets')
    .then( function(data){
      $.each(data.tickets, function(index, ticket){
        countAssignments(ticket);
      });
    console.log( assignmentCount + 'final' );
    getUnassigned(assignmentCount);
    });

});
/* global SW:true */  

$(document).ready(function(){
  'use strict';
  console.log( 'Doing SW things!' );
  var card = new SW.Card();
  var helpdesk = card.services('helpdesk');
  var assignmentCount = {};
  helpdesk
    .request('tickets')
    .then( function(data){
      console.log( 'got data!' );
      $.each(data.tickets, function(index, ticket){
        console.log( ticket.assignee.id );
        if (assignmentCount[ticket.assignee.id]){
          assignmentCount[ticket.assignee.id] += 1;
        } else {
          assignmentCount[ticket.assignee.id] = 1;
        }
        console.log( 'assignmentCount object' );
        console.log( assignmentCount );
      });

      console.log( assignmentCount + 'final' );
      var ticketTotal = 0;
      for (var property in assignmentCount) {
          ticketTotal += assignmentCount[property];
      }
      var unassignedTickets = data.tickets.length - ticketTotal;
      console.log('unassignedTickets');
      console.log(unassignedTickets);
    });

});
--- 
+++ 
@@ -1,4 +1,22 @@
 /* global SW:true */  
+
+var getUnassigned = function (assignmentCount) {
+  var ticketTotal = 0;
+  for (var property in assignmentCount) {
+    ticketTotal += assignmentCount[property];
+  }
+  var unassignedTickets = data.tickets.length - ticketTotal;
+  console.log('unassignedTickets');
+  return unassignedTickets;
+}
+
+var countAssignments = function(ticket){
+  if (assignmentCount[ticket.assignee.id]){
+    assignmentCount[ticket.assignee.id] += 1;
+  } else {
+    assignmentCount[ticket.assignee.id] = 1;
+  }
+};
 
 $(document).ready(function(){
   'use strict';
@@ -6,29 +24,13 @@
   var card = new SW.Card();
   var helpdesk = card.services('helpdesk');
   var assignmentCount = {};
-  helpdesk
-    .request('tickets')
+  helpdesk.request('tickets')
     .then( function(data){
-      console.log( 'got data!' );
       $.each(data.tickets, function(index, ticket){
-        console.log( ticket.assignee.id );
-        if (assignmentCount[ticket.assignee.id]){
-          assignmentCount[ticket.assignee.id] += 1;
-        } else {
-          assignmentCount[ticket.assignee.id] = 1;
-        }
-        console.log( 'assignmentCount object' );
-        console.log( assignmentCount );
+        countAssignments(ticket);
       });
-
-      console.log( assignmentCount + 'final' );
-      var ticketTotal = 0;
-      for (var property in assignmentCount) {
-          ticketTotal += assignmentCount[property];
-      }
-      var unassignedTickets = data.tickets.length - ticketTotal;
-      console.log('unassignedTickets');
-      console.log(unassignedTickets);
+    console.log( assignmentCount + 'final' );
+    getUnassigned(assignmentCount);
     });
 
 });
Move disparate functions into groups of functions to call.
