title: Recursive Switch Statement
body: <p>I am getting a <code>undefined</code> value for a recursive Switch Statement when the <strong>mode</strong> is <strong>random</strong>.  The idea is that is the most id random, it would randomly select a number and set a <strong>new mode</strong> and return the original switch statement.  </p>
  
  <p>Everthing works fine when the mode is not in random.  So I am not sure what is wrong here.<br>
  variable <code>a</code> is the mode, while <code>i,j</code> are simply numbers. </p>
  
  <pre><code>switchMode: function (i, j, a){
              var b;
              console.log(a);
              switch(a) {
                  default:
                  case 'add':
                      console.log(i, j);
                      b = i + j;
                      break;
  
                  case 'minus':
                      console.log(i, j);
                      b = i - j; //negative numbers possible
                      break;
  
                  case 'multiply':
                      console.log(i, j);
                      b = i * j; //0 possible
                      break;  
  
                  case 'random':
                      this.randomSwitchMode(i, j);
                      break; //random
              }   
              return b;
          },
  
  
  
  randomSwitchMode: function(i, j) {
              var c = Math.ceil(Math.random() * 3);
  
              console.log(i, j, c);
  
              switch(c) {
                  default:
                  case 1: 
                      var a = 'add';
                      console.log(a);
                      this.switchMode(i, j, a);
                      break;
  
                  case 2: 
                      var a = 'minus';
                      console.log(a);
                      this.switchMode(i, j, a);
                      break;
  
                  case 3:
                      var a = 'multiply';
                      console.log(a);
                      this.switchMode(i, j, a);
                      break; 
              } 
          }
  </code></pre>