{"action":"created","comment":{"url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/comments/236344714","pull_request_review_id":178401214,"id":236344714,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjM0NDcxNA==","diff_hunk":"@@ -2,38 +2,80 @@\n  * Функция принимает массив\n  * Функция должна вернуть \"настоящюю длинну массива\" [1,2,3,4,5] => 5 | [1,2,3,4, ... пустота... 10] => 5\n  */\n-function trueLength(array) {}\n+function trueLength(array) {\n+  return Object.values(array).length;\n+}\n \n /**\n  * Функция принимает строку, содержащую последовательность круглых, квадратных или фигурных скобок - \"let obj = { numArray: [ ((1 + 2) * 5) + (42).toString() ] }\"\n  * Функция должна вернуть true если все скобки закрыты в правильном порядке или false в противном случае\n  */\n-function isExpressionValid(expression) {}\n+function isExpressionValid(expression) {\n+  let stack = [];\n+  for (let i = 0; i < expression.length; i++) {\n+    let c = expression[i];\n+    switch (c) {\n+      case \"(\":\n+      case \"[\":\n+      case \"{\":\n+        stack.push(expression[i]);\n+        break;\n+      case \")\":\n+        if (stack.pop() !== \"(\") {\n+          return false;\n+        }\n+        break;\n+      case \"]\":\n+        if (stack.pop() !== \"[\") {\n+          return false;\n+        }\n+        break;\n+      case \"}\":\n+        if (stack.pop() !== \"{\") {\n+          return false;\n+        }\n+        break;\n+    }\n+  }\n+  return stack.length == 0;","path":"src/tasks/4_arrays.js","position":41,"original_position":41,"commit_id":"48df8d768c960ab8568375aeae32d73fa27786f2","original_commit_id":"48df8d768c960ab8568375aeae32d73fa27786f2","user":{"login":"sergey-shulyak","id":22372739,"node_id":"MDQ6VXNlcjIyMzcyNzM5","avatar_url":"https://avatars0.githubusercontent.com/u/22372739?v=4","gravatar_id":"","url":"https://api.github.com/users/sergey-shulyak","html_url":"https://github.com/sergey-shulyak","followers_url":"https://api.github.com/users/sergey-shulyak/followers","following_url":"https://api.github.com/users/sergey-shulyak/following{/other_user}","gists_url":"https://api.github.com/users/sergey-shulyak/gists{/gist_id}","starred_url":"https://api.github.com/users/sergey-shulyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergey-shulyak/subscriptions","organizations_url":"https://api.github.com/users/sergey-shulyak/orgs","repos_url":"https://api.github.com/users/sergey-shulyak/repos","events_url":"https://api.github.com/users/sergey-shulyak/events{/privacy}","received_events_url":"https://api.github.com/users/sergey-shulyak/received_events","type":"User","site_admin":false},"body":"Решение верное, но громоздкое, вместо switch с кучей кейсов можно выделить соответствие скобок в словарь (объект или Map) и написать пару if","created_at":"2018-11-26T17:10:48Z","updated_at":"2018-11-26T17:17:41Z","html_url":"https://github.com/sergey-shulyak/js-data-structures/pull/10#discussion_r236344714","pull_request_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/comments/236344714"},"html":{"href":"https://github.com/sergey-shulyak/js-data-structures/pull/10#discussion_r236344714"},"pull_request":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10","id":233577644,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzNTc3NjQ0","html_url":"https://github.com/sergey-shulyak/js-data-structures/pull/10","diff_url":"https://github.com/sergey-shulyak/js-data-structures/pull/10.diff","patch_url":"https://github.com/sergey-shulyak/js-data-structures/pull/10.patch","issue_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/10","number":10,"state":"open","locked":false,"title":"Solutions for tasks","user":{"login":"Dmitriy-Yarygin","id":17846576,"node_id":"MDQ6VXNlcjE3ODQ2NTc2","avatar_url":"https://avatars0.githubusercontent.com/u/17846576?v=4","gravatar_id":"","url":"https://api.github.com/users/Dmitriy-Yarygin","html_url":"https://github.com/Dmitriy-Yarygin","followers_url":"https://api.github.com/users/Dmitriy-Yarygin/followers","following_url":"https://api.github.com/users/Dmitriy-Yarygin/following{/other_user}","gists_url":"https://api.github.com/users/Dmitriy-Yarygin/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmitriy-Yarygin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmitriy-Yarygin/subscriptions","organizations_url":"https://api.github.com/users/Dmitriy-Yarygin/orgs","repos_url":"https://api.github.com/users/Dmitriy-Yarygin/repos","events_url":"https://api.github.com/users/Dmitriy-Yarygin/events{/privacy}","received_events_url":"https://api.github.com/users/Dmitriy-Yarygin/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-11-26T14:31:46Z","updated_at":"2018-11-26T17:17:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6661225eda9d73e7c254c7eb0003dd5c1360182f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10/commits","review_comments_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10/comments","review_comment_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/10/comments","statuses_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/statuses/48df8d768c960ab8568375aeae32d73fa27786f2","head":{"label":"Dmitriy-Yarygin:master","ref":"master","sha":"48df8d768c960ab8568375aeae32d73fa27786f2","user":{"login":"Dmitriy-Yarygin","id":17846576,"node_id":"MDQ6VXNlcjE3ODQ2NTc2","avatar_url":"https://avatars0.githubusercontent.com/u/17846576?v=4","gravatar_id":"","url":"https://api.github.com/users/Dmitriy-Yarygin","html_url":"https://github.com/Dmitriy-Yarygin","followers_url":"https://api.github.com/users/Dmitriy-Yarygin/followers","following_url":"https://api.github.com/users/Dmitriy-Yarygin/following{/other_user}","gists_url":"https://api.github.com/users/Dmitriy-Yarygin/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmitriy-Yarygin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmitriy-Yarygin/subscriptions","organizations_url":"https://api.github.com/users/Dmitriy-Yarygin/orgs","repos_url":"https://api.github.com/users/Dmitriy-Yarygin/repos","events_url":"https://api.github.com/users/Dmitriy-Yarygin/events{/privacy}","received_events_url":"https://api.github.com/users/Dmitriy-Yarygin/received_events","type":"User","site_admin":false},"repo":{"id":158857898,"node_id":"MDEwOlJlcG9zaXRvcnkxNTg4NTc4OTg=","name":"js-data-structures","full_name":"Dmitriy-Yarygin/js-data-structures","private":false,"owner":{"login":"Dmitriy-Yarygin","id":17846576,"node_id":"MDQ6VXNlcjE3ODQ2NTc2","avatar_url":"https://avatars0.githubusercontent.com/u/17846576?v=4","gravatar_id":"","url":"https://api.github.com/users/Dmitriy-Yarygin","html_url":"https://github.com/Dmitriy-Yarygin","followers_url":"https://api.github.com/users/Dmitriy-Yarygin/followers","following_url":"https://api.github.com/users/Dmitriy-Yarygin/following{/other_user}","gists_url":"https://api.github.com/users/Dmitriy-Yarygin/gists{/gist_id}","starred_url":"https://api.github.com/users/Dmitriy-Yarygin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Dmitriy-Yarygin/subscriptions","organizations_url":"https://api.github.com/users/Dmitriy-Yarygin/orgs","repos_url":"https://api.github.com/users/Dmitriy-Yarygin/repos","events_url":"https://api.github.com/users/Dmitriy-Yarygin/events{/privacy}","received_events_url":"https://api.github.com/users/Dmitriy-Yarygin/received_events","type":"User","site_admin":false},"html_url":"https://github.com/Dmitriy-Yarygin/js-data-structures","description":"Repo containing tasks for JS data-structures lecture","fork":true,"url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures","forks_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/forks","keys_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/teams","hooks_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/hooks","issue_events_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/events","assignees_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/tags","blobs_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/languages","stargazers_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/stargazers","contributors_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/contributors","subscribers_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/subscribers","subscription_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/subscription","commits_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/merges","archive_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/downloads","issues_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/labels{/name}","releases_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/Dmitriy-Yarygin/js-data-structures/deployments","created_at":"2018-11-23T16:50:45Z","updated_at":"2018-11-25T11:28:17Z","pushed_at":"2018-11-25T11:28:16Z","git_url":"git://github.com/Dmitriy-Yarygin/js-data-structures.git","ssh_url":"git@github.com:Dmitriy-Yarygin/js-data-structures.git","clone_url":"https://github.com/Dmitriy-Yarygin/js-data-structures.git","svn_url":"https://github.com/Dmitriy-Yarygin/js-data-structures","homepage":null,"size":101,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sergey-shulyak:master","ref":"master","sha":"b3ae186e656a67a61a2b80b17f3ec56514ea1982","user":{"login":"sergey-shulyak","id":22372739,"node_id":"MDQ6VXNlcjIyMzcyNzM5","avatar_url":"https://avatars0.githubusercontent.com/u/22372739?v=4","gravatar_id":"","url":"https://api.github.com/users/sergey-shulyak","html_url":"https://github.com/sergey-shulyak","followers_url":"https://api.github.com/users/sergey-shulyak/followers","following_url":"https://api.github.com/users/sergey-shulyak/following{/other_user}","gists_url":"https://api.github.com/users/sergey-shulyak/gists{/gist_id}","starred_url":"https://api.github.com/users/sergey-shulyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergey-shulyak/subscriptions","organizations_url":"https://api.github.com/users/sergey-shulyak/orgs","repos_url":"https://api.github.com/users/sergey-shulyak/repos","events_url":"https://api.github.com/users/sergey-shulyak/events{/privacy}","received_events_url":"https://api.github.com/users/sergey-shulyak/received_events","type":"User","site_admin":false},"repo":{"id":158389715,"node_id":"MDEwOlJlcG9zaXRvcnkxNTgzODk3MTU=","name":"js-data-structures","full_name":"sergey-shulyak/js-data-structures","private":false,"owner":{"login":"sergey-shulyak","id":22372739,"node_id":"MDQ6VXNlcjIyMzcyNzM5","avatar_url":"https://avatars0.githubusercontent.com/u/22372739?v=4","gravatar_id":"","url":"https://api.github.com/users/sergey-shulyak","html_url":"https://github.com/sergey-shulyak","followers_url":"https://api.github.com/users/sergey-shulyak/followers","following_url":"https://api.github.com/users/sergey-shulyak/following{/other_user}","gists_url":"https://api.github.com/users/sergey-shulyak/gists{/gist_id}","starred_url":"https://api.github.com/users/sergey-shulyak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergey-shulyak/subscriptions","organizations_url":"https://api.github.com/users/sergey-shulyak/orgs","repos_url":"https://api.github.com/users/sergey-shulyak/repos","events_url":"https://api.github.com/users/sergey-shulyak/events{/privacy}","received_events_url":"https://api.github.com/users/sergey-shulyak/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sergey-shulyak/js-data-structures","description":"Repo containing tasks for JS data-structures lecture","fork":false,"url":"https://api.github.com/repos/sergey-shulyak/js-data-structures","forks_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/forks","keys_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/teams","hooks_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/hooks","issue_events_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/events{/number}","events_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/events","assignees_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/assignees{/user}","branches_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/branches{/branch}","tags_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/tags","blobs_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/git/refs{/sha}","trees_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/statuses/{sha}","languages_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/languages","stargazers_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/stargazers","contributors_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/contributors","subscribers_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/subscribers","subscription_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/subscription","commits_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/commits{/sha}","git_commits_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/git/commits{/sha}","comments_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/comments{/number}","issue_comment_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/comments{/number}","contents_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/contents/{+path}","compare_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/merges","archive_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/downloads","issues_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues{/number}","pulls_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls{/number}","milestones_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/milestones{/number}","notifications_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/labels{/name}","releases_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/releases{/id}","deployments_url":"https://api.github.com/repos/sergey-shulyak/js-data-structures/deployments","created_at":"2018-11-20T12:57:09Z","updated_at":"2018-11-23T11:35:45Z","pushed_at":"2018-11-26T14:38:15Z","git_url":"git://github.com/sergey-shulyak/js-data-structures.git","ssh_url":"git@github.com:sergey-shulyak/js-data-structures.git","clone_url":"https://github.com/sergey-shulyak/js-data-structures.git","svn_url":"https://github.com/sergey-shulyak/js-data-structures","homepage":null,"size":93,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":14,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10"},"html":{"href":"https://github.com/sergey-shulyak/js-data-structures/pull/10"},"issue":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/10"},"comments":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/sergey-shulyak/js-data-structures/statuses/48df8d768c960ab8568375aeae32d73fa27786f2"}},"author_association":"NONE"}}
{"actor":{"display_login":"sergey-shulyak"}}