create tic tac toe game in react using jsx files
JavaScript
useEffect(()=>{
//checking winner row and col
for (let i = 0; i <= 2; i++){
const idx = (i % 3) * 3 // -> 0,3,6
//check row
if ( (table[idx] + table[idx+1] + table[idx+2] )=== 9 || (table[idx] + table[idx+1] + table[idx+2] ) === 15){
setWinner([idx,idx+1,idx+2])
gameOver()
}
//check col
if ((table[i] + table[i+3] + table[i+6] )=== 9 || (table[i] + table[i+3] + table[i+6] ) === 15){
setWinner([i,i+3,i+6])
gameOver()
}
}
//checking winner diagonal
if ((table[0] + table[4] + table[8] ) === 15 || (table[0] + table[4] + table[8] ) === 9 ){
setWinner([0, 4, 8])
gameOver()
}
if ((table[2] + table[4] + table[6] ) === 9 || (table[2] + table[4] + table[6] ) ===15){
setWinner([2, 4, 6])
gameOver()
}
// check if table completed
if (table.indexOf(0) === -1){
gameOver()
}
}, [table])
Also in JavaScript:
- Title
- javascript button
- Category
- JavaScript
- Title
- How to pass variables from js to html node
- Category
- JavaScript
- Title
- install php7 runtime brackets
- Category
- JavaScript
- Title
- dataset js
- Category
- JavaScript
- Title
- iterate object js
- Category
- JavaScript
- Title
- how to update jquery datatable row cell value
- Category
- JavaScript
- Title
- bootstrap js cdn
- Category
- JavaScript
- Title
- angular onchange event
- Category
- JavaScript
- Title
- console log all array values node
- Category
- JavaScript
- Title
- foreach w3schools javascript
- Category
- JavaScript
- Title
- if checkbox checked jquery value 1
- Category
- JavaScript
- Title
- check if string is datestring javascript
- Category
- JavaScript
- Title
- add variable numerically in javascript
- Category
- JavaScript
- Title
- fizz buzz javascript
- Category
- JavaScript
- Title
- input set variable angular
- Category
- JavaScript
- Title
- basic javascript
- Category
- JavaScript
- Title
- express url redirect
- Category
- JavaScript
- Title
- how to rescale a canvas in html5 without blurrriness
- Category
- JavaScript
- Title
- abstraction in javascript
- Category
- JavaScript
- Title
- javascript add text to textarea overwrite
- Category
- JavaScript
- Title
- express and node
- Category
- JavaScript
- Title
- array reverse algorithm in js
- Category
- JavaScript
- Title
- import json file javascript
- Category
- JavaScript
- Title
- flatten nested object js
- Category
- JavaScript
- Title
- angular npm angular material
- Category
- JavaScript
- Title
- how to get textedit on mac without download
- Category
- JavaScript
- Title
- arrow function in javascript w3schools
- Category
- JavaScript
- Title
- is var is not blank then display value in javascript
- Category
- JavaScript
- Title
- javascript array column
- Category
- JavaScript
- Title
- how to expire a cookie in javascript
- Category
- JavaScript
- Title
- assign freemarker expressions to variables
- Category
- JavaScript
- Title
- how to draw a triangle using javascript
- Category
- JavaScript
- Title
- angular observable subscribe and unsubscribe
- Category
- JavaScript
- Title
- electron scrollbar
- Category
- JavaScript
- Title
- how to make a calculator websiteJS
- Category
- JavaScript
- Title
- get date javascript
- Category
- JavaScript
- Title
- get value of checked radio button jquery
- Category
- JavaScript
- Title
- Basic JavaScript: Use Recursion to Create a Range of Numbers
- Category
- JavaScript
- Title
- angular ngclass
- Category
- JavaScript
- Title
- A cookie associated with a cross-site resource at http://placeholder.com/ was set without the `SameSite` attribute.
- Category
- JavaScript
- Title
- add select option jquery
- Category
- JavaScript
- Title
- array sort by key javascript
- Category
- JavaScript
- Title
- javascript change meta tag
- Category
- JavaScript
- Title
- javascript Check if an element is a descendant of another
- Category
- JavaScript
- Title
- default pool size in sequelize
- Category
- JavaScript
- Title
- how to manage a db connection in javascript
- Category
- JavaScript
- Title
- Exception in thread "main" org.openqa.selenium.JavascriptException: cannot read getPlayerState
- Category
- JavaScript
- Title
- ExoPlayer with auto linking react native
- Category
- JavaScript
- Title
- install vue js
- Category
- JavaScript
- Title
- discord.js
- Category
- JavaScript
- Title
- foreach and replace item based on condition
- Category
- JavaScript
- Title
- font awesome in react
- Category
- JavaScript
- Title
- chart.js data from mysql vanila javscript
- Category
- JavaScript
- Title
- how to fill false into array javascript
- Category
- JavaScript
- Title
- Date gethours js
- Category
- JavaScript
- Title
- encode url javascript
- Category
- JavaScript
- Title
- click doesn't work on ajax loaded data
- Category
- JavaScript
- Title
- how to define variable in javascript
- Category
- JavaScript
- Title
- how to turn decimales into percents with javascript
- Category
- JavaScript
- Title
- bubble sort
- Category
- JavaScript
- Title
- how to create a server in node js
- Category
- JavaScript
- Title
- include jquery
- Category
- JavaScript
- Title
- forward and reverse loop one by one js
- Category
- JavaScript
- Title
- indexof javascript
- Category
- JavaScript
- Title
- how to find out what a string ends with in javascript
- Category
- JavaScript
- Title
- javascript array of objects access properties
- Category
- JavaScript
- Title
- data-widget="pushmenu" collable automatically
- Category
- JavaScript
- Title
- create an element jquery
- Category
- JavaScript
- Title
- disable button click jquery
- Category
- JavaScript
- Title
- javascript capitalize words
- Category
- JavaScript
- Title
- how to store value in session using javascript in php
- Category
- JavaScript
- Title
- async await promise all javascript
- Category
- JavaScript
- Title
- javascript check if code is nodejs
- Category
- JavaScript
- Title
- Angularjs datetime
- Category
- JavaScript
- Title
- axios post data vue js
- Category
- JavaScript
- Title
- create element javascript with class
- Category
- JavaScript
- Title
- copy to clipboard javascript
- Category
- JavaScript
- Title
- how to check validation for file extension .csv in angular
- Category
- JavaScript
- Title
- double function call javascript
- Category
- JavaScript
- Title
- date picker type react
- Category
- JavaScript
- Title
- javascript class click event
- Category
- JavaScript
- Title
- array of images javascript
- Category
- JavaScript
- Title
- discord.js reply to message
- Category
- JavaScript
- Title
- get a element using name in jquery
- Category
- JavaScript
- Title
- array of array key value javascript
- Category
- JavaScript
- Title
- javascript checkbox value
- Category
- JavaScript
- Title
- convert date to string javascript
- Category
- JavaScript
- Title
- angular @Input()
- Category
- JavaScript
- Title
- check if class is active jquery
- Category
- JavaScript
- Title
- get hash js
- Category
- JavaScript
- Title
- how pass data from body in koa js
- Category
- JavaScript
- Title
- is javascript object oriented
- Category
- JavaScript
- Title
- find duplicates in array of objects javascript
- Category
- JavaScript
- Title
- Javascript compare two arrays
- Category
- JavaScript
- Title
- how to write img jsx
- Category
- JavaScript
- Title
- case in javascript
- Category
- JavaScript
- Title
- javascript canvas beziercurveto
- Category
- JavaScript
- Title
- is object js
- Category
- JavaScript
- Title
- fetch api based on id nodejs and mongodb
- Category
- JavaScript
- Title
- angular date formats
- Category
- JavaScript