Closed jingrid closed 7 years ago
when are you setting these variables?
let boxA = $('#a').text()
let boxB = $('#b').text()
let boxC = $('#c').text()
let boxD = $('#d').text()
let boxE = $('#e').text()
let boxF = $('#f').text()
let boxG = $('#g').text()
let boxH = $('#h').text()
let boxI = $('#i').text()
because if you set them before the boxes are clicked they will all be set to an empty string.
oh I see, but I'm not sure how to define them after the boxes are clicked.
i would argue that you don't even need them. you have an array that represents the state of the board already correct?
Yes, from the patch requests. I've been trying to retrieve the array, but I'm unable to.
Changed all instances of
(boxA === boxB && boxB === boxC && boxA !== '')
....
to
($('#a').text() === $('#b').text() && $('#b').text() === $('#c').text() && $('#a').text() !== '')
.....
which works.
I can't seem to log any wins.
I defined each box and combination of wins:
But when I call the function, it always logs 'not winner.'