dimanche 26 novembre 2017

Javascript: Changing a boolean in an else if statement

i am having the following problem. I am trying to do this but it is not working:

highlight(){

  if (this.firstClick && this.firstMove){
     grid[this.i][this.j+1].toHighlight = true;
     grid[this.i][this.j+2].toHighlight = true;
  } else if (!this.firstClick && this.firstMove) {
     grid[this.i][this.j+1].toHighlight = false;
     grid[this.i][this.j+2].toHighlight = false;
  } else if (this.firtClick && !this.firstMove){
     grid[this.i][this.j+1].toHighlight = true;
     grid[this.i][this.j+2].toHighlight = false;
  } else if (!this.firstClick && !this.firstMove){
     grid[this.i][this.j+1].toHighlight = false;
     grid[this.i][this.j+2].toHighlight = false;
  }

 }

You can look at the full code on my github and how it is working at the moment on the hosted page. I have used it on the black pawn. The white ones have a different logic behind, where i tried something different.

You can find the whole code here: http://ift.tt/2zqVMrS

And it is hosted online here: http://ift.tt/2BmBLns

Aucun commentaire:

Enregistrer un commentaire