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 - JavaScript Tutorial
From the course: Code Clinic: JavaScript
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Intro: Eight queens1m 45s
-
(Locked)
Solution overview1m 31s
-
(Locked)
Preparing the board6m 46s
-
(Locked)
Setting up the board4m 17s
-
(Locked)
Computing solutions3m 56s
-
(Locked)
Finishing calculations7m 23s
-
(Locked)
Storing board solutions4m 1s
-
(Locked)
Display solutions4m 7s
-
(Locked)
Navigating through solutions3m 32s
-
(Locked)
-
-
-