title: I have a declared variable that the code is not recognizing. Why is this?
body: <p>I am programming a game, and this is a portion of it. I want the program to cycle through the different pictures of the sprite running I have uploaded. I made a variable to let the program know which picture is being shown on screen of the character running. The program does not recognize it is a variable being declared. Am I just making a simple mistake with Javascript?</p>
  
  <p>I have tried to move the variable declaration around my code, and put different things inside of it. Nothing seems to work.</p>
  
  <pre><code>class Example1 extends Phaser.Scene {
      constructor() {
          super({key: "Example1"});
  }
  
  //variable for the current running stance which does not work
  var playerBoard = 1;
      preload() {
          this.load.image('Background', 'assets/Background.jpg');
          this.load.image('4 JUMP_000', 'assets/4 JUMP_000.png');
          let run1 = this.load.image('3 RUN_000', 'assets/3 RUN_000.png');
          let run2 = this.load.image('3 RUN_001', 'assets/3 RUN_001.png');
          let run3 = this.load.image('3 RUN_002', 'assets/3 RUN_002.png');
          let run4 = this.load.image('3 RUN_003', 'assets/3 RUN_003.png');
          let run5 = this.load.image('3 RUN_004', 'assets/3 RUN_004.png');
  
      }
  /*another variable to help return to the first running stance when the sprite stops running*/
  let runningStance = run1;
  //function that switches the running stances
  runningScene(x,y){
  
  if(this.input.keyboard.on("keyDown_D")){
    while(this.input.keyboard.on("keyDown_D")) {
       if (this.playerBoard = 1) {
           this.playerBoard1 = 2;
           this.image = this.add.image(this.image.x, this.image.y, '3 RUN_001');
           runningStance = run2;
           run1.visable = false;
      }
  </code></pre>
  
  <p>Some of the code from the program is not included as it would take up too much space. What is not working is the declaration of the variable, as it does not allow the if function to work properly. I have phaser installed, which you can refer to in the code. The output is supposed to hide the starting picture and show the next in the sequence, which will be run2.</p>