title: How to use "readline()" function in JavaScript?
body: <p>I was learning <a href="http://www.cnblogs.com/SHERO-Vae/p/5945294.html" rel="nofollow noreferrer">去哪儿网-2017笔试题</a> and programing. In my program, I want to use <code>readline()</code> function to read a single line from input from <code>stdin</code>. I know that  <code>readline()</code> function belongs to <strong>JavaScript Shell</strong> according to <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Introduction_to_the_JavaScript_shell#readline.28.29" rel="nofollow noreferrer">MDN</a>. But the function is not defined when I run the code in my browser. </p>
  
  <pre class="lang-js prettyprint-override"><code>var line;
  while (line = read_line()) {
    while (line.indexOf(" ") != -1) {
      line = line.replace(" ", "");
    }
    if (line.length &lt;= 6) {
      print(line);
    } else if (line.length &gt; 6 &amp;&amp; line.length &lt;= 14) {
      var line1 = line.substring(0, 6);
      var line2 = line.substring(6);
      print(line1 + " " + line2);
    } else if (line.length &gt; 14 &amp;&amp; line.length &lt;= 18) {
      var line1 = line.substring(0, 6);
      var line2 = line.substring(6, 14);
      var line3 = line.substring(14);
      print(line1 + " " + line2 + " " + line3);
    }
  }
  </code></pre>
  
  
  
  <p>If I want to run the code in my browser. What should I do? </p>
  
  <p>Thank you very much.</p>