{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/234","repository_url":"https://api.github.com/repos/ga-wdi-boston/game-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/234/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/234/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/234/events","html_url":"https://github.com/ga-wdi-boston/game-project/issues/234","id":168201959,"number":234,"title":"Issue with Jquery Selector ","user":{"login":"natGalynker","id":18671336,"avatar_url":"https://avatars.githubusercontent.com/u/18671336?v=3","gravatar_id":"","url":"https://api.github.com/users/natGalynker","html_url":"https://github.com/natGalynker","followers_url":"https://api.github.com/users/natGalynker/followers","following_url":"https://api.github.com/users/natGalynker/following{/other_user}","gists_url":"https://api.github.com/users/natGalynker/gists{/gist_id}","starred_url":"https://api.github.com/users/natGalynker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natGalynker/subscriptions","organizations_url":"https://api.github.com/users/natGalynker/orgs","repos_url":"https://api.github.com/users/natGalynker/repos","events_url":"https://api.github.com/users/natGalynker/events{/privacy}","received_events_url":"https://api.github.com/users/natGalynker/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-07-28T21:32:07Z","updated_at":"2016-07-28T22:00:21Z","closed_at":null,"body":"I have been having some issues with game logic and trying to parse out the steps needed to get the game up and running. I was making good progress, but when my code broke earlier today I had to go back to a simpler version. Right now the issue I am having is that when I try to select an element with the jquery selector to print out the value to the console, it returns as undefined. I have tried cutting back the code to only having the click handler and a console log, but even that is not working. This was not a problem earlier today and I cannot figure out the steps needed to fix this. \r\n\r\n```\r\n'use strict';\r\nlet turnTracker = 0;\r\nlet marker = ' ';\r\nlet currentPlayer = ' ';\r\nlet boardArray = [];\r\n\r\nconst checkForDraw = function(){\r\n  console.log(\"It's a Draw!\");\r\n  let draw = false;\r\n  console.log(\"It's a tie!\");\r\n  if (turnTracker >= 8){\r\n    draw = true;\r\n    console.log(\"It's a Cats Game\");\r\n  }\r\n  return draw;\r\n};\r\n\r\nconst checkForWin = function () {\r\n  let win = false;\r\n\r\n  if(currentPlayer === boardArray[0] && currentPlayer === boardArray[1] && currentPlayer === boardArray[2] ||\r\n    currentPlayer === boardArray[3] && currentPlayer === boardArray[4] && currentPlayer === boardArray[5] ||\r\n    currentPlayer === boardArray[6] && currentPlayer === boardArray[7] && currentPlayer === boardArray[8] ||\r\n    currentPlayer === boardArray[0] && currentPlayer === boardArray[3] && currentPlayer === boardArray[6] ||\r\n    currentPlayer === boardArray[1] && currentPlayer === boardArray[4] && currentPlayer === boardArray[7] ||\r\n    currentPlayer === boardArray[2] && currentPlayer === boardArray[5] && currentPlayer === boardArray[8] ||\r\n    currentPlayer === boardArray[0] && currentPlayer === boardArray[4] && currentPlayer === boardArray[8] ||\r\n    currentPlayer === boardArray[2] && currentPlayer === boardArray[4] && currentPlayer === boardArray[6] ){\r\n      win = true;\r\n      console.log(\"winner is\" +currentPlayer);\r\n    }\r\n    return win;\r\n  };\r\n\r\n  const swapPlayer = function(){\r\n    if(turnTracker % 2 === 0) {\r\n      currentPlayer = \"Player X\";\r\n      marker = \"X\";\r\n      turnTracker++;\r\n    } else {\r\n      currentPlayer = \"Player O\";\r\n      marker =  \"O\";\r\n      turnTracker++;\r\n    }\r\n  };\r\n  const setGame = function(){\r\n    //clear the board\r\n    boardArray = [];\r\n    boardArray[0] = null;\r\n    boardArray[1] = null;\r\n    boardArray[2] = null;\r\n    boardArray[3] = null;\r\n    boardArray[4] = null;\r\n    boardArray[5] = null;\r\n    boardArray[6] = null;\r\n    boardArray[7] = null;\r\n    boardArray[8] = null;\r\n  //set first player\r\n  currentPlayer = \"Player X\";\r\n  marker = \"X\";\r\n};\r\n\r\nconst cellAvailable = function (index) {\r\n  //check to see if cell is open for moves\r\n  console.log(\"checking cell\"+ index);\r\n};\r\n\r\nconst cellTaken = function (index) {\r\n  //mark cell as occupied\r\n  console.log(\"marking cell\" + index);\r\n};\r\n$(() => {\r\n  //initialize gameboard\r\n  setGame();\r\n  $('.main').on('click', 'div', swapPlayer(){\r\n    console.log($(this).data('data-number'));\r\n      let index = parseInt($(this).attr('data-number'));\r\n      console.log(\"checking square occupied index\" +index);\r\n      if($(this).text() !== \"X\" && $(this).text() !== \"O\") {\r\n        if(cellAvailable(index)){\r\n          //mark square taken\r\n          cellTaken(index);\r\n        }\r\n\r\n        $(this).text(marker);\r\n        // console.log(marker);\r\n        // console.log(boardArray);\r\n        // console.log(index);\r\n        // swapPlayer();\r\n        if(checkForWin()){\r\n          //game is done! display player won with .text maybe\r\n        }else if(checkForDraw){\r\n        //Display that its a cats game\r\n      }else{\r\n        //game continues\r\n      }\r\n      swapPlayer();\r\n      //isDraw();\r\n      // setGame();\r\n    }\r\n}\r\n\r\n};\r\nmodule.exports = {\r\n  swapPlayer,\r\n  checkForDraw,\r\n  checkForWin,\r\n  setGame\r\n};\r\n```"},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/comments/236038365","html_url":"https://github.com/ga-wdi-boston/game-project/issues/234#issuecomment-236038365","issue_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/234","id":236038365,"user":{"login":"laurenfazah","id":8062679,"avatar_url":"https://avatars.githubusercontent.com/u/8062679?v=3","gravatar_id":"","url":"https://api.github.com/users/laurenfazah","html_url":"https://github.com/laurenfazah","followers_url":"https://api.github.com/users/laurenfazah/followers","following_url":"https://api.github.com/users/laurenfazah/following{/other_user}","gists_url":"https://api.github.com/users/laurenfazah/gists{/gist_id}","starred_url":"https://api.github.com/users/laurenfazah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laurenfazah/subscriptions","organizations_url":"https://api.github.com/users/laurenfazah/orgs","repos_url":"https://api.github.com/users/laurenfazah/repos","events_url":"https://api.github.com/users/laurenfazah/events{/privacy}","received_events_url":"https://api.github.com/users/laurenfazah/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T22:00:20Z","updated_at":"2016-07-28T22:00:20Z","body":"Let's try it with the jQuery selector then. Have you tried `$('space').on(click, function(){console.log(\"clicked\")})`?"}}
{"actor":{"display_login":"laurenfazah"}}