DEV Community

loading...

Connect Four in JavaScript (video)

ania_kubow profile image Ania Kubow ・2 min read

A retro grid-based game in vanilla JavaScript, HTML and CSS

Connect Four (also known as Four Up, Plot Four, Find Four, Four in a Row, Four in a Line, Drop Four, and Gravitrips (in Soviet Union)) is a two-player board game in which the players first choose a color and then take turns dropping one colored disc from the top into a seven-column, six-row vertically suspended grid. The pieces fall straight down, occupying the lowest available space within the column. The objective of the game is to be the first to form a horizontal, vertical, or diagonal line of four of one's own discs.

What are we going to focus on?

  • for loops
  • Array work
  • onclick()

Rules of Connect Four

  • You will start as player One
  • You will take your go as player One
  • You will not be allowed to go in squares that are not at the bottom of the grid, or do not have a taken square under it
  • Once your go is taken and you did not win, It will be player Two's go
  • The gamer will continue until a winning combination of four is reached by player One or player Two, or until the grid is full and no winning combination was found.


Links:

-Sign up for weekly coding tips from my newsletter partnership: https://bit.ly/JS-tips

I would love to see what you made so please tag me :
Twitter: https://twitter.com/ania_kubow
Instagram: https://www.instagram.com/aniakubow

Oh and please do Subscribe and hit that bell button! It would mean a lot to me and motivate me to make more videos for you all!

javascript

javscriptGames

Discussion (0)

pic
Editor guide