Build Tic Tac Toe With JavaScript - Tutorial

Поделиться
HTML-код
  • Опубликовано: 2 июн 2024
  • Learning web development can be tough and boring, but it doesn't have to be. In this video we take a look at creating an advanced JavaScript tic tac toe game. This is a great project for anyone that wants to create a fun project while learning advanced JavaScript and CSS concepts.
    📚 Materials/References:
    GitHub Code: github.com/WebDevSimplified/J...
    CodePen Code: codepen.io/WebDevSimplified/p...
    JavaScript Defer Attribute Tutorial: • What Is The Fastest Wa...
    Why I Do Not Use Class Selectors In JS Article: blog.webdevsimplified.com/201...
    CSS Variables Tutorial: • CSS Variables Tutorial
    Array Destructoring Tutorial: • Why Is Array/Object De...
    🧠 Concepts Covered:
    - Advanced CSS Hover Effects
    - Advanced JS Game Logic
    - CSS Not Selector
    - CSS Shape Building
    🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    #TicTacToe #WDS #JavaScript

Комментарии • 482

  • @jakecooley7603
    @jakecooley7603 4 года назад +263

    Right when I thought I was getting the hang of CSS!

  • @nathanwijayasekara
    @nathanwijayasekara 2 года назад +81

    Best way to remove the side borders is by not putting borders at all but just use gird-grap to create the lines. No need to separating selecting the elements and removing them.
    .board {
    display: grid;
    grid-gap: 5px;
    grid-template-columns: repeat(3, auto);
    background-color: black;
    }
    .cell {
    background-color: white;
    width: var(--cell-size);
    height: var(--cell-size);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    }

  • @nicholasdejong7112
    @nicholasdejong7112 4 года назад +17

    we need more people like this man! He is shaping a new vision to help beginners do what they want!

  • @chasec4897
    @chasec4897 3 года назад +31

    I never thought Id find the day Id finish a youtube tutorial. Been trying to learn programing for years, and recently came across a really good web development course, got the fundamentals and finally really learn't web development and wanted to create a tic tac toe game just curious of the logic. I managed to do my own, but I had started this one before I started my own, and had to come back to see how this one was created because I was fasinated by the design and how good the tutorial is. Mine came nowehere close to how good this is. Thank you so much man !!!

    • @kebab4640
      @kebab4640 Год назад +1

      may I ask, what web development course you took? I know how to do the javascript but the css was honestly the most difficult.

    • @chasec4897
      @chasec4897 Год назад

      @@kebab4640 Hi Mate, CSS I found the hardest. Funnily enough, I mastered js and react but right this moment Im once again going through my old courses on css. I had purchased a course on udemy advanced css by Jonas. Its extremely good for responsiveness, and flex box any many things. But these have been at me for years, Im pretty sure net ninja has it all covered as well. Just keep practising, and don't rush things, and very imp experiment.

  • @cameronrowe2032
    @cameronrowe2032 2 года назад +4

    Kyle knows his onions! His designs are so thorough, and his use of ES6 functionality and CSS is masterful in its elegance. Great tutorial, with a lot of material illustrated clearly and accurately in application towards delivering a nice little application :) .

  • @nkosinathimazibuko2561
    @nkosinathimazibuko2561 3 года назад +1

    This is my first year coding and I have to say that this is by far the most impressive thing I have seen

  • @itahirk
    @itahirk 4 года назад +131

    Such a tricky project made so simple. Thank you so much Kyle.

    • @rajab4187
      @rajab4187 4 года назад +4

      I left it out in my college exam
      In c++

    • @piyushgargdev
      @piyushgargdev Год назад

      I made same project using ReactJS - ruclips.net/video/pw2krTJLF6Y/видео.html

  • @kenchang3456
    @kenchang3456 3 года назад +4

    This is such a timely topic for me as my wife wants me to help her create a math game proof of concept and this will be a great foundation. Thank you very much for the detailed explanation.

  • @dalilapramenkovic8597
    @dalilapramenkovic8597 2 года назад +5

    Thank you! You've made this so easy to understand. This really is web dev simplified!

  • @tremolony4924
    @tremolony4924 3 года назад +4

    I'm not skilled enough to create these projects on my own...
    BUT this is what I have learnt by following along & making your Clock, Quiz & Tic Tac Toe Projects
    - Debugging skills are getting faster & way more effective
    - Recognizing patterns & having a somewhat better understanding of wtf is going on
    - Implementing your logic & workflow
    Thanks so much & I hope to become a great Programmer / Web Developer & one day give back to the community in anyway I can.

    • @arvsnacs422
      @arvsnacs422 2 года назад +1

      Same here. Ive done the clock, quiz, calculator, and now im trying to understand this. Im a self learner and no background just youtube and google.

    • @tremolony4924
      @tremolony4924 2 года назад

      @@arvsnacs422 Keep pushing!!! Don't give up

    • @arvsnacs422
      @arvsnacs422 2 года назад

      @@tremolony4924 sometimes i get discourage because when i do the project again i cant run it right. And sometimes wonder how did they come up with that approach and did they did it a day or what. I dont expect but I will try to learn and get there someday.

    • @tremolony4924
      @tremolony4924 2 года назад +2

      ​@@arvsnacs422 Yes I agree. It can be discouraging when the project doesn't work...
      Most people give up when it gets too difficult...
      Keep learning & keep doing small projects. It takes time but eventually you will improve :)

  • @Billy_98
    @Billy_98 4 года назад +6

    Thank you,man! This clip was amazing!

  • @derekprieur5258
    @derekprieur5258 Год назад

    Great tutorial! Your style gives me a good mix of learning new things (especially in the CSS of this video) and allowing me to try to implement the current part first before I watch you do it

  • @blank-ui4lp
    @blank-ui4lp Год назад +4

    every single time I watch your videos I need to stand back and question everything I know,
    because of how incredibly clean and easy the code you teach is to learn
    thank you so so much!

  • @trevormuhoni
    @trevormuhoni 4 года назад +31

    me:iam wondering why iam thinking of learning css again,
    kyle:This is why

  • @aaronlauretani8921
    @aaronlauretani8921 Год назад +1

    Clear and detailed explanations, and extremely well-organized. Great video.

  • @roseboutique-womensalterat1216
    @roseboutique-womensalterat1216 3 года назад +3

    wow, great project. I'm very impressed with the use of advanced CSS and what it can do for a website. It helped me a lot to code my tic-tac-toe game. great tutorial, indeed very high quality coding skills ....

  • @utsikko
    @utsikko 2 года назад +2

    So super effective and straight to the point! Awesome!

  • @TheSparkyack
    @TheSparkyack Год назад +1

    This was a great film. Works great with great explanation! Keep the videos coming!

  • @ainederrick8948
    @ainederrick8948 4 года назад

    I like how you get what I'm thinking about and put it in code, with so much ease.

  • @Brandon-sr4qp
    @Brandon-sr4qp 2 года назад +4

    I really enjoyed the use of different CSS selectors, thanks for that. I came for the JavaScript, but I stayed for the styles. Lol

  • @mattc3265
    @mattc3265 4 года назад

    Nice video Kyle, you always put out great material!

  • @TThessful
    @TThessful 3 года назад +4

    Thank you for great tutorials! You are really good at this :)

  • @LabhamJain
    @LabhamJain 4 года назад

    After Watching This Video I've Realized Why Say I've Two Yrs Of Experience...
    You're A Great Man Kyle! Hats off 👏👏

  • @carterjm
    @carterjm 3 года назад +1

    You are really good man. I love how CSS can be used in place of JavaScript.

  • @TheRealBwoi
    @TheRealBwoi 4 года назад +2

    The real question is how do you make an NxN Tic Tac Toe game with dynamic win conditions?
    Love your videos. Extremely clear and thorough. You're my go to reference when I get stuck at work and the answer isn't on Stack Overflow.

  • @azizkhujakhujaev2598
    @azizkhujakhujaev2598 4 года назад +6

    Hey Kyle thank you for the good video🤙🏼 I would like to ask you could you make video about your background how did you learn programming(front-end) which books did you read and courses did you used?! Thanks advance I do appreciate you job👍🏻

  • @thefunnyoz
    @thefunnyoz 4 года назад +2

    Such a joy to watch you code and explain these projects and topics! Thank you!

  • @josephsanjivi795
    @josephsanjivi795 2 года назад +1

    Hello Kyle,
    While declaring border-top: none in your CSS for the cells, you could just write nth-child(-n+3) instead of writing three lines. The same goes for border-bottom: none as well

  • @leeyahav4754
    @leeyahav4754 3 года назад

    that checkWin function is amazing with the logic ,
    I would not thought about doing this function by my self
    thnx a lot .
    that project has tought me a lot

  • @foochertyi3714
    @foochertyi3714 2 года назад +20

    Note: If your having a problem in 25:06 in CSS part, unable to hide the winning-message
    Solution: Try removing the ' display: flex; ' in side the winning-message and add it inside the ' winning-message .show '

    • @OShaunB
      @OShaunB Год назад

      thanks

    • @deepakantoj432
      @deepakantoj432 9 месяцев назад

      in 12:20 why does adding [ display : flex ] on .cell{ } show the before and after divs.
      why not without it ?

  • @stevehollis544
    @stevehollis544 3 года назад +1

    so so good - I learned loads from this

  • @minnuss
    @minnuss 3 года назад +7

    On 8:50, for top and bottom border lines, you can do :
    .cell:nth-child(1n+1) {
    border-top: none;
    }
    .cell:nth-child(1n+7) {
    border-bottom: none;
    }

    • @deepakantoj432
      @deepakantoj432 9 месяцев назад

      in 12:20 why does adding [ display : flex ] on .cell{ } show the before and after divs.
      why not without it ?

  • @rauts_arad
    @rauts_arad 3 года назад

    Thanks Kyle!!! Awesome Tutorial!

  • @wadebekker7108
    @wadebekker7108 3 года назад

    Thanks Kyle! I’m curious to know how you decided on which ‘const’ names have uppercase vs camel case. Much appreciated! Love your channel man.

  • @ethanswedlund1886
    @ethanswedlund1886 Год назад +1

    Can't say thanks enough for the helpful thorough informative lesson

  • @ankitagarwal4914
    @ankitagarwal4914 3 года назад

    Thank you! You have provided a lot ! I have learned a lot from this tutorial.

  • @rangabharath4253
    @rangabharath4253 4 года назад +1

    Thank you so much. Awesome as always 😀👍👌

  • @nukez88
    @nukez88 4 года назад

    I had a project in collage that I didn't mange to finish. It was a game called Nim. I was supposed to make the game so that you can play it against the PC (The class was virtual intelligence) ,but I didn't manage to make it smart enough so made something else. This seems pretty cool so I will try it . Thanks for the idea.

  • @Flora-ho4eo
    @Flora-ho4eo 2 года назад

    I love your tutorials. You're the best.

  • @hansschenker
    @hansschenker 3 года назад

    Super CSS Combinators Exercise: Could fill a whole course on CSS Combinators! Thank's a lot Kyle for this carefully crafted presentation!!

  • @lordofdawn6871
    @lordofdawn6871 2 года назад +1

    I love your videos because you explain very well thank you kyle :)

  • @harshsugandhi07
    @harshsugandhi07 3 года назад

    Hey, you made the JavaScript part much much simpler than the normal one!!!

  • @billyzman666
    @billyzman666 2 года назад

    Your videos are so great! thank you!

  •  4 года назад +13

    Very nicely done!
    Though, personally, I'd use inline SVG for drawing the board, as well as the noughts and crosses. But that's just a personal preference: my main reason for this is the fact I abhor using any more CSS than absolutely necessary to get things working. I find SVG perfectly suited for tasks such as these, as it gives me much more versatility, and I find it easier to maintain and tweak later.

    • @85percentcocoa
      @85percentcocoa 2 года назад +1

      exactly my thoughts. SVG is best suited for a non real-time game, and CSS is best kept to a minimum. it is much easier to use JS to handle dynamic changes in CSS, rather than to do acrobatics with HTML and CSS and query gimnastics which are useless for most projects. BUT, this video is VERY good as a learning tool, it takes you to places you may not think of and it does it brilliantly. so, thank you WDS, you really are helpful!

  • @miscellaneouscell
    @miscellaneouscell Год назад

    You have earned a subscriber! You an excellent teacher. I am very impressed.

  • @shavetasidana5135
    @shavetasidana5135 3 года назад

    always amazing got my project easily done thank you kyle(:

  • @RameenFallschirmjager
    @RameenFallschirmjager 4 года назад +49

    Hello Kyle. These days your face has become one of my own family! Every time I see you a new video, I feel genuine happiness!

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +12

      Thank you so much! That really means a ton.

    • @RameenFallschirmjager
      @RameenFallschirmjager 4 года назад

      @@WebDevSimplified Thank you brother❤ I hope someday I can appreciate you in a tangible way. Words are not enough to show gratitude for your immense contribution.

    • @wd1534
      @wd1534 4 года назад +1

      @@WebDevSimplified Hi Kyle! Is it possible to make this game playing remotely with a friend? 2 remotely players? Somebody is interested to develop this functionality with me? Any help is welcome!

    • @ferzinhaN
      @ferzinhaN 3 года назад

      That's so sweet😄

  • @ivanamagden
    @ivanamagden 4 года назад

    Fast paced, but awesome. You're great btw.

  • @uncleslo910
    @uncleslo910 Месяц назад

    Still valid, exceptional teaching skills, thank you.

  • @Wintastic
    @Wintastic 3 года назад

    thanks for this video, it helped me better understand when it's a good idea to define new functions.

  • @shubhamh7451
    @shubhamh7451 3 года назад

    INSANE. Pure genius!

  • @basiccodingwithadam8125
    @basiccodingwithadam8125 4 года назад

    Great video and a fun project that I want to try!

  • @namalashivacharan2789
    @namalashivacharan2789 3 года назад +3

    You explained it very well. I just want to give simple suggestion. To get initial hover effect, you just need to add x_class to board class.

    • @YuriG03042
      @YuriG03042 Год назад

      that assumes that X always starts

  • @basiccodingwithadam8125
    @basiccodingwithadam8125 4 года назад +3

    Your use of CSS in this video is that of a master. Kudos to you sir.

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +1

      Thank you so much. I love how powerful CSS is now. It makes doing things like this so much easier then it used to be.

    • @deepakantoj432
      @deepakantoj432 9 месяцев назад

      in 12:20 why does adding [ display : flex ] on .cell{ } show the before and after divs.
      why not without it ?@@WebDevSimplified

  • @technonessteam7511
    @technonessteam7511 3 года назад

    So detailed tutorial
    Just Amazing!

  • @tvo7781
    @tvo7781 4 года назад

    Great video as always. Thanks.

  • @roney23jj
    @roney23jj 4 года назад +1

    wow!! i watched the video 5 times! great show & tell :-)

  • @satyabratadash2858
    @satyabratadash2858 4 года назад +8

    Thanks bro, I'm waiting for this project, hope you will come with these types of advance projects....... 👍👍👍

    • @WebDevSimplified
      @WebDevSimplified  4 года назад +6

      I plan to make more advanced projects like this in the future

    • @satyabratadash2858
      @satyabratadash2858 4 года назад

      @@WebDevSimplified thanks a lot ,,, we are waiting........

    • @020amsterda020
      @020amsterda020 4 года назад +2

      @@WebDevSimplified goat.

  • @viewer9022
    @viewer9022 4 года назад +1

    Loved this one

  • @demarco6967
    @demarco6967 4 года назад

    thanks sir, learned new cool stuff watching this video

  • @usama57926
    @usama57926 4 года назад +1

    wow amazing tutorial.... i love this channel

  • @topellasrinivasarao1125
    @topellasrinivasarao1125 4 года назад +6

    You are Really Talented and you deserve more than 1M subs Good Luck .BTW Small projects playlist is best for me to learn something new while quarantined.
    I Said you deserve more subs cuz lotta channels out there recommend their own sh*t instead the real content but you are unlike 'em ensures quality of content Again Good Luck
    Love from India

  • @callmeFernie
    @callmeFernie 3 года назад +5

    There's too much going on here! haha Thanks, Kyle! Much appreciate it

  • @joel_mathew
    @joel_mathew 2 года назад +2

    Web Dev Simplified : makes a quiz website in 26 minutes .
    also Web Dev Simplified :makes tic tac toe in 41 minutes.
    by the way love your videos

  • @gopalloharnew5948
    @gopalloharnew5948 2 года назад +1

    Awesome man !!!

  • @Chadner
    @Chadner 3 года назад

    Awesome tutorial! 5 stars!

  • @jit3191
    @jit3191 3 года назад

    Excellent video, thank you

  • @chnaka7518
    @chnaka7518 11 месяцев назад

    Just simple styles in the game.But learnt a lot more than expected

  • @Snooker219
    @Snooker219 2 года назад +3

    I only started coding a few weeks ago, but I don't think that programmers say this lot Kyle's favorite sentence: "which is exactly what we want" 😂. Great videos btw. How much time does it take for you to create a program like this for the first time?

  • @nicholasjoiles8999
    @nicholasjoiles8999 Год назад

    Great explanation. Thank you 🤏

  • @ValeyValeAventuras
    @ValeyValeAventuras 3 года назад +1

    Thanks Kyle, your videos are awesome! I am new to JavaScript if you have a full class please let me know, i want in!

  • @maskman4821
    @maskman4821 4 года назад

    this game has a lot to do with css, kind of complicated, but good to learn all the basic, and it is a good game, a great tutorial, Mr. Kyle is a mater !!!

  • @marytsach6450
    @marytsach6450 3 года назад

    Accessible and helpfull.
    Nice teacher and nice work!

  • @Dinostorm
    @Dinostorm 4 года назад

    Best channel on youtube :)

  • @izyo8146
    @izyo8146 2 года назад

    You're awesome, thank you!

  • @wiffec
    @wiffec 4 года назад

    MAAAN keep it up, great work great developer very nice very helpful... Keep with you amazing work!

  • @angelpeace2350
    @angelpeace2350 4 года назад +2

    Thank you, so amazing

  • @Gormlessostrich
    @Gormlessostrich 3 года назад

    Many thanks, Kyle!

  • @lunarmoon999
    @lunarmoon999 Год назад

    man I did this on my own and it had literally 20xs more code and was not nearly as clean as this LOL its so good to see it being done in a much more simplified way

    • @bulaloitech
      @bulaloitech Год назад

      Same, mine was around 110 lines of code for 2 player and 288 for computer

  • @zainabalhaidary
    @zainabalhaidary 3 года назад

    You deserve wayyy more subscribers

  • @KumarAcademy
    @KumarAcademy 3 года назад +14

    You are GEM:))

  • @uimonk
    @uimonk 3 года назад

    thank you kyle.. you are awesome.

  • @sergiomedina5520
    @sergiomedina5520 2 года назад

    Thank you so much for your help. Before this video, this game was too difficult to program.

  • @BipinKumar-yq5ho
    @BipinKumar-yq5ho Год назад

    Bro,Your Video is so amazing

  • @DaK1ller
    @DaK1ller Год назад

    thank you so much man!

  • @wangyifei5431
    @wangyifei5431 4 года назад

    First comment after I become a big fan of Kyle. Really good job for each video. Thx a lot for ur great job !

  • @Dararezuyeacademy
    @Dararezuyeacademy 2 года назад

    Thanks, good luck!

  • @GarySSBM
    @GarySSBM 3 года назад

    Fantastic content and production quality, thank you for this!

  • @iben1195
    @iben1195 2 года назад +1

    Next Level CSS!

  • @neevbadu3611
    @neevbadu3611 Год назад

    Well Explained.. Thanks..

  • @clemensh6214
    @clemensh6214 4 года назад +3

    Very Amazing tutorial. I'm asking me how do you get this ideas the way you are programming. I mean If I see your tutorial I'm understanding what you are doing but by my self I would never write such code without getting inspired with tutorials like that. So I think you have to be some kind of hyper intelligent to develope those applications without watching tutorials. Or is there any trick ?

  • @kevinneel07
    @kevinneel07 3 года назад

    Thanks for the help 👍

  • @lilitvardanyan2275
    @lilitvardanyan2275 Год назад

    Thank You so much!

  • @dirtygeisha3120
    @dirtygeisha3120 Год назад +6

    33:30 I've been learning JS for 2month. My head started burning with that part 🤦‍♂️

    • @jimknopf9077
      @jimknopf9077 Год назад +1

      Never give up.

    • @felipeleon6631
      @felipeleon6631 Год назад

      enjoy the process of understanding, there's always going to be something that you don't understand. But be concious about the progress

  • @pengfeijia3748
    @pengfeijia3748 4 года назад +1

    Great Video. My question is why the click event listener has to be removed in the startGame() since the listener is set up with once: true?

  • @solo3659
    @solo3659 4 года назад

    Thank you so much brother you are awesome

  • @ravalravi882
    @ravalravi882 3 года назад +1

    every(), some() contain() what the hell is this ... i never come acress this method kyal ..(By The Its Really awsome)
    learn a Lot .. Love from India ....Keep it up

  • @amidfallen
    @amidfallen 2 года назад +1

    Nice. I would like to see it implemented with ES6 classes.

  • @Bahadurpk
    @Bahadurpk 4 года назад

    Excellent video...

  • @TechnoDB
    @TechnoDB 4 года назад +1

    Awesome!!