Skip to content

Conversation

@JB-Walker
Copy link
Owner

Created Mastermind Visual as an object.

Copy link

@reneemeyer reneemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

James, over all- really nice job. Just a few method questions/suggestions below. Also a note: it seems in your code you seem to take the long way around. Just because a method is available doesn't mean that you should use it. I like the idea of using classes, but there are a multitude of es6 array methods that would simply this code a lot and make it more effective. Now that the game works, I would refactor with the intent of getting rid of all for loops and all nested loops.


class MasterMind {
constructor () {
// All Global Constants

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice commenting!

processStart () {
// Clear board on restart - not first game
if (this.currentRow !== null) {
for (let row = 0; row < this.maxChecks; row++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could you do this without using nested loops?

// Determines remaining number of colors in the guess that match remaining
// colors in the solution
for (let guessIndex = 0; guessIndex < this.codeLength; guessIndex++) {
for (let solutionIndex = 0; solutionIndex < this.codeLength; solutionIndex++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a nested loop here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants