{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/237","repository_url":"https://api.github.com/repos/ga-wdi-exercises/project1","labels_url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/237/comments","events_url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/237/events","html_url":"https://github.com/ga-wdi-exercises/project1/issues/237","id":136165466,"number":237,"title":"game crashes","user":{"login":"Crunchwrap78","id":14954458,"avatar_url":"https://avatars.githubusercontent.com/u/14954458?v=3","gravatar_id":"","url":"https://api.github.com/users/Crunchwrap78","html_url":"https://github.com/Crunchwrap78","followers_url":"https://api.github.com/users/Crunchwrap78/followers","following_url":"https://api.github.com/users/Crunchwrap78/following{/other_user}","gists_url":"https://api.github.com/users/Crunchwrap78/gists{/gist_id}","starred_url":"https://api.github.com/users/Crunchwrap78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crunchwrap78/subscriptions","organizations_url":"https://api.github.com/users/Crunchwrap78/orgs","repos_url":"https://api.github.com/users/Crunchwrap78/repos","events_url":"https://api.github.com/users/Crunchwrap78/events{/privacy}","received_events_url":"https://api.github.com/users/Crunchwrap78/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"RobertAKARobin","id":6268177,"avatar_url":"https://avatars.githubusercontent.com/u/6268177?v=3","gravatar_id":"","url":"https://api.github.com/users/RobertAKARobin","html_url":"https://github.com/RobertAKARobin","followers_url":"https://api.github.com/users/RobertAKARobin/followers","following_url":"https://api.github.com/users/RobertAKARobin/following{/other_user}","gists_url":"https://api.github.com/users/RobertAKARobin/gists{/gist_id}","starred_url":"https://api.github.com/users/RobertAKARobin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RobertAKARobin/subscriptions","organizations_url":"https://api.github.com/users/RobertAKARobin/orgs","repos_url":"https://api.github.com/users/RobertAKARobin/repos","events_url":"https://api.github.com/users/RobertAKARobin/events{/privacy}","received_events_url":"https://api.github.com/users/RobertAKARobin/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-02-24T19:38:49Z","updated_at":"2016-02-24T20:01:00Z","closed_at":null,"body":"I'm trying to implement the difficulty level, but the game crashes when I do. It works without the difficulty. The question is why does it crash?\r\n\r\n```js\r\nvar imgCards=[ \"https://lh3.googleusercontent.com/ZZPdzvlpK9r_Df9C3M7j1rNRi7hhHRvPhlklJ3lfi5jk86Jd1s0Y5wcQ1QgbVaAP5Q=w300\",\r\n    \"https://lh3.googleusercontent.com/ZZPdzvlpK9r_Df9C3M7j1rNRi7hhHRvPhlklJ3lfi5jk86Jd1s0Y5wcQ1QgbVaAP5Q=w300\",\r\n    \"https://g.twimg.com/Twitter_logo_blue.png\",\r\n    \"https://g.twimg.com/Twitter_logo_blue.png\",\r\n    \"http://us.mullenlowe.com/wp-content/uploads//2013/10/instagramlogo.jpg\",\r\n    \"http://us.mullenlowe.com/wp-content/uploads//2013/10/instagramlogo.jpg\",\r\n    \"http://theappshowbox.com/wp-content/uploads/2015/10/LinkedIn-Logo.png\",\r\n    \"http://theappshowbox.com/wp-content/uploads/2015/10/LinkedIn-Logo.png\",\r\n    \"https://62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com/files/93616/area14mp/image-20150902-6700-t2axrz.jpg\",\r\n    \"https://62e528761d0685343e1c-f3d1b99a743ffa4142d9d7f1978d9686.ssl.cf2.rackcdn.com/files/93616/area14mp/image-20150902-6700-t2axrz.jpg\",\r\n    \"https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png\",\r\n    \"https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png\",\r\n    \"http://archiveteam.org/images/1/15/Apple-logo.jpg\",\r\n    \"http://archiveteam.org/images/1/15/Apple-logo.jpg\",\r\n    \"http://dri1.img.digitalrivercontent.net/Storefront/Site/msusa/images/promo/en-US/msstore_400x400.jpg\",\r\n    \"http://dri1.img.digitalrivercontent.net/Storefront/Site/msusa/images/promo/en-US/msstore_400x400.jpg\",\r\n    \"http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons/3d-glossy-green-orbs-icons-alphanumeric/102895-3d-glossy-green-orb-icon-alphanumeric-dollar-sign.png\",\r\n    \"http://cdn.mysitemyway.com/etc-mysitemyway/icons/legacy-previews/icons/3d-glossy-green-orbs-icons-alphanumeric/102895-3d-glossy-green-orb-icon-alphanumeric-dollar-sign.png\",\r\n    \"http://www.multimedialab.be/blog/wp-content/uploads/2009/04/logo_ps.gif\",\r\n    \"http://www.multimedialab.be/blog/wp-content/uploads/2009/04/logo_ps.gif\"\r\n  ];\r\nvar flipCard=[];\r\nvar flippedCards = 0;\r\nvar counter =0\r\nvar choice = prompt(\"What game difficulty do you want? \\n Easy \\n Medium \\n Hard\");\r\nchoice = choice.toLowerCase();\r\n\r\nfunction shuffleCards(){\r\n  Array.prototype.shuffle = function()\r\n  {\r\n    var i = this.length, j, temp;\r\n    while ( --i )\r\n    {\r\n      j = Math.floor( Math.random() * (i + 1));\r\n      temp = this[i];\r\n      this[i] = this[j];\r\n      this[j] = temp;\r\n    }\r\n  };\r\n  imgCards.shuffle();\r\n}\r\n\r\n\r\nfunction makeBoard(){\r\n  shuffleCards();\r\n  var board = '';\r\n  for( var i = 0; i<imgCards.length; i++){\r\n    board += '<div class = \"card\">'\r\n    board += '<img src = \"'+imgCards[i]+'\"/>'\r\n    board += '</div>'\r\n  }\r\n  document.getElementById('gamePlace').innerHTML = board;\r\n  document.getElementsByTagName(\"p\")[0].innerHTML = \"flipped cards: \"+ counter;\r\n  $(\"img\").hide();\r\n}\r\n\r\nif(choice === \"hard\"){\r\n  counter = 50;\r\n  do {\r\n    makeBoard();\r\n    $(\".card\").click(function(){\r\n      if ((flipCard.length < 2) && ($(this).children(\"img\").hasClass(\"up\")) === false) {\r\n        $(this).children(\"img\").css(\"background-color\",\"white\");\r\n        $(this).children(\"img\").show();\r\n        $(this).children(\"img\").addClass(\"up\");\r\n        if (flipCard.length === 0){\r\n          flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n          counter--;\r\n          document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter;\r\n        }\r\n        else if (flipCard.length === 1) {\r\n            flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n            counter--;\r\n            document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter;\r\n            if(flipCard[0]===flipCard[1]){\r\n              $(\".card\").children(\"img[src='\"+flipCard[1]+\"']\").addClass(\"match\");\r\n              flippedCards += 2;\r\n              flipCard =[];\r\n              if(flippedCards === imgCards.length){\r\n                document.getElementsByTagName(\"p\")[0].innerHTML = \"You Completed the Game. The amount of flips you have left is \"+ counter;\r\n              }\r\n            }\r\n            else{\r\n              setTimeout(function() {\r\n              $(\"img\").not(\".match\").hide();\r\n              $(\"img\").not(\".match\").removeClass(\"up\");\r\n              }, 500);\r\n              flipCard =[];\r\n            }\r\n         }\r\n       }\r\n\r\n    });\r\n\r\n  } while (counter > 0);\r\n  if (counter === 0) {\r\n    document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter + \"\\n Game Over!\";\r\n  }\r\n\r\n}\r\nelse if(choice === \"medium\"){\r\n  counter = 75;\r\n  do {\r\n    makeBoard();\r\n    $(\".card\").click(function(){\r\n      if ((flipCard.length < 2) && ($(this).children(\"img\").hasClass(\"up\")) === false) {\r\n        $(this).children(\"img\").css(\"background-color\",\"white\");\r\n        $(this).children(\"img\").show();\r\n        $(this).children(\"img\").addClass(\"up\");\r\n        if (flipCard.length === 0){\r\n          flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n          counter--;\r\n          document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter;\r\n        }\r\n        else if (flipCard.length === 1) {\r\n            flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n            counter--;\r\n            document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter;\r\n            if(flipCard[0]===flipCard[1]){\r\n              $(\".card\").children(\"img[src='\"+flipCard[1]+\"']\").addClass(\"match\");\r\n              flippedCards += 2;\r\n              flipCard =[];\r\n              if(flippedCards === imgCards.length){\r\n                document.getElementsByTagName(\"p\")[0].innerHTML = \"You Completed the Game. The amount of flips you have left is \"+ counter;\r\n              }\r\n            }\r\n            else{\r\n              setTimeout(function() {\r\n              $(\"img\").not(\".match\").hide();\r\n              $(\"img\").not(\".match\").removeClass(\"up\");\r\n              }, 500);\r\n              flipCard =[];\r\n            }\r\n         }\r\n       }\r\n\r\n    });\r\n\r\n  } while (counter > 0);\r\n  if (counter === 0) {\r\n    document.getElementsByTagName(\"p\")[0].innerHTML = \"flips left: \"+ counter + \"\\n Game Over!\";\r\n  }\r\n}\r\nelse if (choice === \"easy\") {\r\n  makeBoard();\r\n  $(\".card\").click(function(){\r\n    if ((flipCard.length < 2) && ($(this).children(\"img\").hasClass(\"up\")) === false) {\r\n      $(this).children(\"img\").css(\"background-color\",\"white\");\r\n      $(this).children(\"img\").show();\r\n      $(this).children(\"img\").addClass(\"up\");\r\n      if (flipCard.length === 0){\r\n        flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n        counter++;\r\n        document.getElementsByTagName(\"p\")[0].innerHTML = \"flipped cards: \"+ counter;\r\n      }\r\n      else if (flipCard.length === 1) {\r\n          flipCard.push($(this).children(\"img\").attr(\"src\"));\r\n          counter++;\r\n          document.getElementsByTagName(\"p\")[0].innerHTML = \"flipped cards: \"+ counter;\r\n          if(flipCard[0]===flipCard[1]){\r\n            $(\".card\").children(\"img[src='\"+flipCard[1]+\"']\").addClass(\"match\");\r\n            flippedCards += 2;\r\n            flipCard =[];\r\n            if(flippedCards === imgCards.length){\r\n              document.getElementsByTagName(\"p\")[0].innerHTML = \"You Completed the Game. Your flip count is \"+ counter;\r\n            }\r\n          }\r\n          else{\r\n            setTimeout(function() {\r\n            $(\"img\").not(\".match\").hide();\r\n            $(\"img\").not(\".match\").removeClass(\"up\");\r\n            }, 500);\r\n            flipCard =[];\r\n          }\r\n       }\r\n     }\r\n\r\n  });\r\n\r\n}\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n// // window.addEventListener(makeBoard());\r\n"},"comment":{"url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/comments/188431902","html_url":"https://github.com/ga-wdi-exercises/project1/issues/237#issuecomment-188431902","issue_url":"https://api.github.com/repos/ga-wdi-exercises/project1/issues/237","id":188431902,"user":{"login":"Crunchwrap78","id":14954458,"avatar_url":"https://avatars.githubusercontent.com/u/14954458?v=3","gravatar_id":"","url":"https://api.github.com/users/Crunchwrap78","html_url":"https://github.com/Crunchwrap78","followers_url":"https://api.github.com/users/Crunchwrap78/followers","following_url":"https://api.github.com/users/Crunchwrap78/following{/other_user}","gists_url":"https://api.github.com/users/Crunchwrap78/gists{/gist_id}","starred_url":"https://api.github.com/users/Crunchwrap78/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Crunchwrap78/subscriptions","organizations_url":"https://api.github.com/users/Crunchwrap78/orgs","repos_url":"https://api.github.com/users/Crunchwrap78/repos","events_url":"https://api.github.com/users/Crunchwrap78/events{/privacy}","received_events_url":"https://api.github.com/users/Crunchwrap78/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T20:01:00Z","updated_at":"2016-02-24T20:01:00Z","body":"That's the thing. I don't know. It won't let me open up the console. I can show the no difficulty version if you'd like an idea. \r\n"}}