From the course: Code Clinic: JavaScript

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Setting up the board

Setting up the board - JavaScript Tutorial

From the course: Code Clinic: JavaScript

Start my 1-month free trial

Setting up the board

- [Instructor] This problem has a lot of code, so we're going to need to break it up into achievable chunks, and the first thing we will do is work on creating our board class. This is what's going to allow us to create the board for the project, so we'll create a function and call it Board, traditionally we capitalize things that behave like classes and then we're gonna have to set up some variables here, so we'll say this.width is going to be equal to the number of columns, so we call that numColumns up there, and then we will do lastRow, so we're going to need to figure out how big the board is. We already can see that, but we need to describe it to the computer, so this will be the width minus one, and that's because whenever you get a number of columns and then you convert it to an array notation, array's are zero-indexed so you start with zero, and if we had eight columns then the last element would be seven so that's why we're doing that here, so that should be width, and we'll…

Contents