{"action":"created","comment":{"url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/comments/29226038","id":29226038,"diff_hunk":"@@ -0,0 +1,112 @@\n+var Bowling = function(){\n+  this.rollsArray = [];\n+  this.scoresArray = [];\n+  this.rollCounter = 0;\n+  this.frameCounter = 1;\n+};\n+\n+Bowling.prototype.roll = function(rollScore){\n+  var self = this;\n+\n+  function throwAlert(){\n+    alert(\"Illegal score\");\n+  };\n+\n+  function isIllegalScore(){\n+    return self.frameCounter % 2 === 0 && (rollScore + self.scoresArray[self.scoresArray.length - 1] > 10);\n+  };\n+\n+  if (isIllegalScore()){\n+    throwAlert();\n+  } else {\n+    self.rollsArray.push(rollScore);\n+    self.registerRoll(rollScore);\n+  };\n+};\n+\n+Bowling.prototype.registerRoll = function(rollScore){\n+  var self = this;\n+\n+  function tenthFrame (){\n+    return self.frameCounter > 18;\n+  };\n+\n+  function isStrike(){\n+    return rollScore === 10;\n+  };\n+\n+  function isFrameEnd(){\n+    return self.frameCounter % 2 === 0;\n+  };\n+\n+  function isSpare(){\n+    return rollScore + self.scoresArray[self.scoresArray.length - 1] === 10;\n+  };\n+\n+  function decideSpare(){\n+    if (isSpare()){\n+      self.scoresArray.push('/');\n+    } else {\n+      self.scoresArray.push(rollScore);\n+    };\n+    self.frameCounter ++;\n+  };\n+\n+  function pushScore(){\n+    self.scoresArray.push(rollScore);\n+  };\n+\n+  if (tenthFrame()){\n+    pushScore();\n+  } else if (isStrike()){\n+    pushScore();\n+    self.scoresArray.push('X');\n+    self.frameCounter += 2;\n+  } else if (isFrameEnd()){\n+    decideSpare();\n+  } else {\n+    pushScore();\n+    self.frameCounter ++;\n+  };\n+  self.rollCounter ++;\n+};","path":"src/Bowling.js","position":72,"original_position":72,"commit_id":"9ece44c09f8bff36adacce2db38dbfd1c77eaa00","original_commit_id":"9ece44c09f8bff36adacce2db38dbfd1c77eaa00","user":{"login":"spike01","id":7307631,"avatar_url":"https://avatars.githubusercontent.com/u/7307631?v=3","gravatar_id":"","url":"https://api.github.com/users/spike01","html_url":"https://github.com/spike01","followers_url":"https://api.github.com/users/spike01/followers","following_url":"https://api.github.com/users/spike01/following{/other_user}","gists_url":"https://api.github.com/users/spike01/gists{/gist_id}","starred_url":"https://api.github.com/users/spike01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spike01/subscriptions","organizations_url":"https://api.github.com/users/spike01/orgs","repos_url":"https://api.github.com/users/spike01/repos","events_url":"https://api.github.com/users/spike01/events{/privacy}","received_events_url":"https://api.github.com/users/spike01/received_events","type":"User","site_admin":false},"body":"Have the helper functions below the main execution - helps a lot for readability","created_at":"2015-04-28T09:21:18Z","updated_at":"2015-04-28T09:21:18Z","html_url":"https://github.com/makersacademy/bowling-challenge/pull/21#discussion_r29226038","pull_request_url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21","_links":{"self":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/comments/29226038"},"html":{"href":"https://github.com/makersacademy/bowling-challenge/pull/21#discussion_r29226038"},"pull_request":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21"}}},"pull_request":{"url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21","id":33608697,"html_url":"https://github.com/makersacademy/bowling-challenge/pull/21","diff_url":"https://github.com/makersacademy/bowling-challenge/pull/21.diff","patch_url":"https://github.com/makersacademy/bowling-challenge/pull/21.patch","issue_url":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/21","number":21,"state":"open","locked":false,"title":"Pull Request","user":{"login":"sanjsanj","id":4478671,"avatar_url":"https://avatars.githubusercontent.com/u/4478671?v=3","gravatar_id":"","url":"https://api.github.com/users/sanjsanj","html_url":"https://github.com/sanjsanj","followers_url":"https://api.github.com/users/sanjsanj/followers","following_url":"https://api.github.com/users/sanjsanj/following{/other_user}","gists_url":"https://api.github.com/users/sanjsanj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanjsanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanjsanj/subscriptions","organizations_url":"https://api.github.com/users/sanjsanj/orgs","repos_url":"https://api.github.com/users/sanjsanj/repos","events_url":"https://api.github.com/users/sanjsanj/events{/privacy}","received_events_url":"https://api.github.com/users/sanjsanj/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-18T20:58:35Z","updated_at":"2015-04-28T09:21:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"61b911696efa4fd4333a94d1555057c24c121036","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21/commits","review_comments_url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21/comments","review_comment_url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/comments{/number}","comments_url":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/21/comments","statuses_url":"https://api.github.com/repos/makersacademy/bowling-challenge/statuses/9ece44c09f8bff36adacce2db38dbfd1c77eaa00","head":{"label":"sanjsanj:master","ref":"master","sha":"9ece44c09f8bff36adacce2db38dbfd1c77eaa00","user":{"login":"sanjsanj","id":4478671,"avatar_url":"https://avatars.githubusercontent.com/u/4478671?v=3","gravatar_id":"","url":"https://api.github.com/users/sanjsanj","html_url":"https://github.com/sanjsanj","followers_url":"https://api.github.com/users/sanjsanj/followers","following_url":"https://api.github.com/users/sanjsanj/following{/other_user}","gists_url":"https://api.github.com/users/sanjsanj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanjsanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanjsanj/subscriptions","organizations_url":"https://api.github.com/users/sanjsanj/orgs","repos_url":"https://api.github.com/users/sanjsanj/repos","events_url":"https://api.github.com/users/sanjsanj/events{/privacy}","received_events_url":"https://api.github.com/users/sanjsanj/received_events","type":"User","site_admin":false},"repo":{"id":34136012,"name":"bowling-challenge","full_name":"sanjsanj/bowling-challenge","owner":{"login":"sanjsanj","id":4478671,"avatar_url":"https://avatars.githubusercontent.com/u/4478671?v=3","gravatar_id":"","url":"https://api.github.com/users/sanjsanj","html_url":"https://github.com/sanjsanj","followers_url":"https://api.github.com/users/sanjsanj/followers","following_url":"https://api.github.com/users/sanjsanj/following{/other_user}","gists_url":"https://api.github.com/users/sanjsanj/gists{/gist_id}","starred_url":"https://api.github.com/users/sanjsanj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sanjsanj/subscriptions","organizations_url":"https://api.github.com/users/sanjsanj/orgs","repos_url":"https://api.github.com/users/sanjsanj/repos","events_url":"https://api.github.com/users/sanjsanj/events{/privacy}","received_events_url":"https://api.github.com/users/sanjsanj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sanjsanj/bowling-challenge","description":"Calculate Scores for Ten Pin Bowling","fork":true,"url":"https://api.github.com/repos/sanjsanj/bowling-challenge","forks_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/forks","keys_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/teams","hooks_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/hooks","issue_events_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/issues/events{/number}","events_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/events","assignees_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/assignees{/user}","branches_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/branches{/branch}","tags_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/tags","blobs_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/git/refs{/sha}","trees_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/statuses/{sha}","languages_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/languages","stargazers_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/stargazers","contributors_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/contributors","subscribers_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/subscribers","subscription_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/subscription","commits_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/commits{/sha}","git_commits_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/git/commits{/sha}","comments_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/comments{/number}","issue_comment_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/issues/comments{/number}","contents_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/contents/{+path}","compare_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/merges","archive_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/downloads","issues_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/issues{/number}","pulls_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/pulls{/number}","milestones_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/milestones{/number}","notifications_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/labels{/name}","releases_url":"https://api.github.com/repos/sanjsanj/bowling-challenge/releases{/id}","created_at":"2015-04-17T19:30:50Z","updated_at":"2015-04-26T19:20:48Z","pushed_at":"2015-04-26T19:20:48Z","git_url":"git://github.com/sanjsanj/bowling-challenge.git","ssh_url":"git@github.com:sanjsanj/bowling-challenge.git","clone_url":"https://github.com/sanjsanj/bowling-challenge.git","svn_url":"https://github.com/sanjsanj/bowling-challenge","homepage":null,"size":441,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"makersacademy:master","ref":"master","sha":"b843922086b56762415dd07ed1649a9ad294b58c","user":{"login":"makersacademy","id":3636186,"avatar_url":"https://avatars.githubusercontent.com/u/3636186?v=3","gravatar_id":"","url":"https://api.github.com/users/makersacademy","html_url":"https://github.com/makersacademy","followers_url":"https://api.github.com/users/makersacademy/followers","following_url":"https://api.github.com/users/makersacademy/following{/other_user}","gists_url":"https://api.github.com/users/makersacademy/gists{/gist_id}","starred_url":"https://api.github.com/users/makersacademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makersacademy/subscriptions","organizations_url":"https://api.github.com/users/makersacademy/orgs","repos_url":"https://api.github.com/users/makersacademy/repos","events_url":"https://api.github.com/users/makersacademy/events{/privacy}","received_events_url":"https://api.github.com/users/makersacademy/received_events","type":"Organization","site_admin":false},"repo":{"id":27005859,"name":"bowling-challenge","full_name":"makersacademy/bowling-challenge","owner":{"login":"makersacademy","id":3636186,"avatar_url":"https://avatars.githubusercontent.com/u/3636186?v=3","gravatar_id":"","url":"https://api.github.com/users/makersacademy","html_url":"https://github.com/makersacademy","followers_url":"https://api.github.com/users/makersacademy/followers","following_url":"https://api.github.com/users/makersacademy/following{/other_user}","gists_url":"https://api.github.com/users/makersacademy/gists{/gist_id}","starred_url":"https://api.github.com/users/makersacademy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/makersacademy/subscriptions","organizations_url":"https://api.github.com/users/makersacademy/orgs","repos_url":"https://api.github.com/users/makersacademy/repos","events_url":"https://api.github.com/users/makersacademy/events{/privacy}","received_events_url":"https://api.github.com/users/makersacademy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/makersacademy/bowling-challenge","description":"Calculate Scores for Ten Pin Bowling","fork":false,"url":"https://api.github.com/repos/makersacademy/bowling-challenge","forks_url":"https://api.github.com/repos/makersacademy/bowling-challenge/forks","keys_url":"https://api.github.com/repos/makersacademy/bowling-challenge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/makersacademy/bowling-challenge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/makersacademy/bowling-challenge/teams","hooks_url":"https://api.github.com/repos/makersacademy/bowling-challenge/hooks","issue_events_url":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/events{/number}","events_url":"https://api.github.com/repos/makersacademy/bowling-challenge/events","assignees_url":"https://api.github.com/repos/makersacademy/bowling-challenge/assignees{/user}","branches_url":"https://api.github.com/repos/makersacademy/bowling-challenge/branches{/branch}","tags_url":"https://api.github.com/repos/makersacademy/bowling-challenge/tags","blobs_url":"https://api.github.com/repos/makersacademy/bowling-challenge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/makersacademy/bowling-challenge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/makersacademy/bowling-challenge/git/refs{/sha}","trees_url":"https://api.github.com/repos/makersacademy/bowling-challenge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/makersacademy/bowling-challenge/statuses/{sha}","languages_url":"https://api.github.com/repos/makersacademy/bowling-challenge/languages","stargazers_url":"https://api.github.com/repos/makersacademy/bowling-challenge/stargazers","contributors_url":"https://api.github.com/repos/makersacademy/bowling-challenge/contributors","subscribers_url":"https://api.github.com/repos/makersacademy/bowling-challenge/subscribers","subscription_url":"https://api.github.com/repos/makersacademy/bowling-challenge/subscription","commits_url":"https://api.github.com/repos/makersacademy/bowling-challenge/commits{/sha}","git_commits_url":"https://api.github.com/repos/makersacademy/bowling-challenge/git/commits{/sha}","comments_url":"https://api.github.com/repos/makersacademy/bowling-challenge/comments{/number}","issue_comment_url":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/comments{/number}","contents_url":"https://api.github.com/repos/makersacademy/bowling-challenge/contents/{+path}","compare_url":"https://api.github.com/repos/makersacademy/bowling-challenge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/makersacademy/bowling-challenge/merges","archive_url":"https://api.github.com/repos/makersacademy/bowling-challenge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/makersacademy/bowling-challenge/downloads","issues_url":"https://api.github.com/repos/makersacademy/bowling-challenge/issues{/number}","pulls_url":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls{/number}","milestones_url":"https://api.github.com/repos/makersacademy/bowling-challenge/milestones{/number}","notifications_url":"https://api.github.com/repos/makersacademy/bowling-challenge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/makersacademy/bowling-challenge/labels{/name}","releases_url":"https://api.github.com/repos/makersacademy/bowling-challenge/releases{/id}","created_at":"2014-11-22T17:07:53Z","updated_at":"2015-04-11T11:16:35Z","pushed_at":"2015-04-27T10:22:01Z","git_url":"git://github.com/makersacademy/bowling-challenge.git","ssh_url":"git@github.com:makersacademy/bowling-challenge.git","clone_url":"https://github.com/makersacademy/bowling-challenge.git","svn_url":"https://github.com/makersacademy/bowling-challenge","homepage":null,"size":4254,"stargazers_count":1,"watchers_count":1,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":48,"mirror_url":null,"open_issues_count":19,"forks":48,"open_issues":19,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21"},"html":{"href":"https://github.com/makersacademy/bowling-challenge/pull/21"},"issue":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/21"},"comments":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/issues/21/comments"},"review_comments":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21/comments"},"review_comment":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/pulls/21/commits"},"statuses":{"href":"https://api.github.com/repos/makersacademy/bowling-challenge/statuses/9ece44c09f8bff36adacce2db38dbfd1c77eaa00"}}}}