lib/pages.js
function commonUserName(objs, logger){
  logger.info('finding common username');
  var i = objs.length,
      x = 0
      usernames = [],
      highest = 0, 
      out ='';

  while (x < i) {
      appendName(objs[x].userName);
      x++;
  }

  var i = usernames.length;
  while (i--) {
    if(usernames[i].count > highest){
      highest = usernames[i].count;
      out = usernames[i].name;
    }
  }

  function appendName(userName){
    var i = usernames.length;
    while (i--) {
      if(usernames[i].name === userName){
        usernames[i].count ++;
        return;
      }
    }
    usernames.push({
      'name': userName, 
      'count': 1
    })
  }

  return out;
}
function commonUserName(objs, logger){
  logger.info('finding common username');
  var i = objs.length,
      x = 0
      usernames = [],
      highest = 0, 
      out ='';

  while (x < i) {
      appendName(objs[x].userName);
      x++;
  }

  var i = usernames.length;
  while (i--) {
    if(usernames[i].count > highest){
      highest = usernames[i].count;
      out = usernames[i].name;
    }
  }

  function appendName(userName){
    var i = usernames.length;
    while (i--) {
      if(usernames[i].name === userName){
        usernames[i].count ++;
        return;
      }
    }
    usernames.push({
      'name': userName, 
      'count': 1
    })
  }

  return out;
}
function commonUserName ( objs , logger ) { logger . info ( 'finding common username' ) ; var i = objs . length , x = 0 usernames = [ ] , highest = 0 , out = '' ; while ( x < i ) { appendName ( objs [ x ] . userName ) ; x ++ ; } var i = usernames . length ; while ( i -- ) { if ( usernames [ i ] . count > highest ) { highest = usernames [ i ] . count ; out = usernames [ i ] . name ; } } function appendName ( userName ) { var i = usernames . length ; while ( i -- ) { if ( usernames [ i ] . name === userName ) { usernames [ i ] . count ++ ; return ; } } usernames . push ( { 'name' : userName , 'count' : 1 } ) } return out ; }
find the most common username by freguency of use
find the most common username by freguency of use