GithubHelp home page GithubHelp logo

tic-tac-toe's Introduction

<title>tictactoe</title> <style> h1{ text-align:center; } * { background-color:lavender; } table tr,th,td{ background-color:pink; } table.center { margin-left: auto; margin-right: auto; } </style>

TIC TAC TOE

Welcome to the world of tic tac toe

Player one will start with "x" and player two will start with "0"



<script> flag=1; function fun1() { if(flag==1){ document.getElementById("a").value="x"; flag=0;} else { document.getElementById("a").value="0"; flag=1; } } function fun2() { if(flag==1){ document.getElementById("b").value="x"; flag=0;} else{ document.getElementById("b").value="0"; flag=1; } }
  function fun3()
     {
        if(flag==1){
           document.getElementById("c").value="x";
           flag=0;}
       else
          {
           document.getElementById("c").value="0";
           flag=1;
     }
   }
   function fun4()
     {
        if(flag==1){
           document.getElementById("d").value="x";
           flag=0;}
       else
         { 
           document.getElementById("d").value="0";
           flag=1;
     }
   }
 function fun5()
     {
        if(flag==1){
           document.getElementById("e").value="x";
           flag=0;}
       else {             
           document.getElementById("e").value="0";
           flag=1; 
        }        
   }
 function fun6()
     {
        if(flag==1){
           document.getElementById("f").value="x";
           flag=0;}
       else   {         
           document.getElementById("f").value="0";
           flag=1;  
        }    
   }
function fun7()
     {
        if(flag==1){
           document.getElementById("g").value="x";
           flag=0;}
       else    {          
           document.getElementById("g").value="0";
           flag=1;
     }
   }
 function fun8()
     {
        if(flag==1){
           document.getElementById("h").value="x";
           flag=0;}
       else{
           document.getElementById("h").value="0";
           flag=1;
        }       
   }
  function fun9()
     {
        if(flag==1){
           document.getElementById("i").value="x";
           flag=0;}
       else{
           document.getElementById("i").value="0";
           flag=1;  
       }       
   }
 function logic()
    {
          one=document.getElementById("a").value; 
          two=document.getElementById("b").value; 
        three=document.getElementById("c").value;
          four=document.getElementById("d").value;
         five=document.getElementById("e").value;
         six=document.getElementById("f").value;
         seven=document.getElementById("g").value;
         eight=document.getElementById("h").value;
         nine=document.getElementById("i").value; 
    
   if(one=="x"&&two=="x"&&three=="x")
     {
        alert("x won");
     }
    else if(one=="0"&&two=="0"&&three=="0")
     {
       alert("0 won");
     }
   else if(four=="x"&&five=="x"&&six=="x")
     {
       alert("x won");
     }
   else if(four=="0"&&five=="0"&&six=="0")
     {
       alert("0 won");
     }
    else if(seven=="x"&&eight=="x"&&nine=="x")
     {
       alert("x won");
     }
    else if(seven=="0"&&eight=="0"&&nine=="0")
     {
       alert("0 won");
     }
  else if(one=="x"&&five=="x"&&nine=="x")
      {
         alert("x won");
      }
   else if(one=="0"&&five=="0"&&nine=="0")
      {
         alert("0 won");
      }
 else if(three=="x"&&five=="x"&&seven=="x")
      {
         alert("x won");
      }
  else if(three=="0"&&five=="0"&&seven=="0")
      {
         alert("0 won");
      }
  else if(one=="x"&&four=="x"&&seven=="x")
     {
        alert("x won");
     }
   else if(one=="0"&&four=="0"&&seven=="0")
     {
        alert("0 won");
     } 
   else if(two=="x"&&five=="x"&&eight=="x")
     {
        alert("x won");
     } 
   else if(two=="0"&&five=="0"&&eight=="0")
     {
        alert("0 won");
     } 
   else if(three=="x"&&six=="x"&&nine=="x")
     {
        alert("x won");
     } 
    else if(three=="0"&&six=="0"&&nine=="0")
     {
        alert("0 won");
     } 

} </script>

tic-tac-toe's People

Contributors

srijarayikanti avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.