DoSomething/ds-mdata-responder — pull request #223 by tongxiang (2014-10-16 19:57:14+00:00)
Title: Issue214

#### What's this PR do?
Previously, our app was crashing because of the error below. (The alignment may be off here, but the nextRank[j].phone was throwing "Cannot read property 'phone' of undefined.)

The nextRank object was getting populated by an "undefined object", which I'm guessing could happen if playerRankArray was empty, and nextRank was populated by undefined.

Unfortunately, try as I might, I wasn't able to replicate this issue. I moved the `playerRankArray.length` check at the start of the loop and added a check to make sure that the `nextRank[j].phone` property was defined within the loop.

#### How should this be manually tested?
Using Postman, play through Science Sleuth (game id 101) for multiple players until the end. It should accurately assign rank to the users and not crash.
```
[10/14 13:25:25 EDT][err] if (gameDoc.players_current_status[k].phone == nextRank[j].phone) {
[10/14 13:25:25 EDT][err] ^
[10/14 13:25:25 EDT][err] TypeError: Cannot read property 'phone' of undefined
[10/14 13:25:25 EDT][err] at SGCompetitiveStoryController.getIndivRankEndGameMessage (/opt/run/snapshot/package/app/controllers/SGCompetitiveStoryController.js:1154:69)
[10/14 13:25:25 EDT][err] at SGCompetitiveStoryController.getUniqueIndivEndGameMessage (/opt/run/snapshot/package/app/controllers/SGCompetitiveStoryController.js:1078:17)
[10/14 13:25:25 EDT][err] at execUserAction (/opt/run/snapshot/package/app/controllers/SGCompetitiveStoryController.js:644:30)
[10/14 13:25:25 EDT][err] at Promise.onGameFound (/opt/run/snapshot/package/app/controllers/SGCompetitiveStoryController.js:739:7)
[10/14 13:25:25 EDT][err] at Promise. (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mpromise/lib/promise.js:177:8)
[10/14 13:25:25 EDT][err] at Promise.emit (events.js:95:17)
[10/14 13:25:25 EDT][err] at Promise.emit (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mpromise/lib/promise.js:84:38)
[10/14 13:25:25 EDT][err] at Promise.fulfill (/opt/run/snapshot/package/node_modules/mongoose/node_modules/mpromise/lib/promise.js:97:20)
[10/14 13:25:25 EDT][err] at /opt/run/snapshot/package/node_modules/mongoose/lib/query.js:1394:13
[10/14 13:25:25 EDT][err] at model.Document.init (/opt/run/snapshot/package/node_modules/mongoose/lib/document.js:250:11)
[10/14 13:25:25 EDT][err] /opt/run/snapshot/package/app/controllers/SGCompetitiveStoryController.js:1154
```
#### What are the relevant tickets?
#### Questions: