title: Using node.js's prompt for user input?
body: <p>I'm working on a JS project running with node.js and I can't figure out how to get the prompt to work correctly for user input. I installed it from npm, followed the steps and I can get the program to prompt for user input but I can't store the result in a variable.</p>
  
  <p>What I want is to prompt the user for his next move (up,down,left or right) every turn and use the result. I tried making a global <em>move</em> variable and affecting it in the prompt section, but it doesn't seem to work.</p>
  
  <pre><code>  var Moving = function(maxMoves){
  
      for(var n=maxMoves; n&gt;0;){
          var move;
          var l;
          //This would prompt for a direction (up,down,left,right)
          move = prompt();
          //And this would prompt for the number of tiles to advance;
          l = prompt();
          Direction(move,l);
          n-=l;
      }
  };
  </code></pre>