title: Run JavaScript codes in Visual Studio code terminal same as what works in browser's console
body: <p>This is a basic vs code question, but I'm kinda new to this code editor. I need to run/ <code>console.log()</code>  a  simple js script in vs code platform  same as what works in the browser's console or this &quot;code snippet&quot;. Just for example of my simple js script:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const data = parseInt(prompt("5 x 5?"));
  const testResult = (answer) =&gt; data === answer ? console.log(`Correct. Your answer was: ${data}`) : console.log(`Incorrect. Your answer was: ${data}. Pls try again`)
  
  testResult(25);</code></pre>
  </div>
  </div>
  </p>
  <p>If I <code>console.log()</code> this in the browser, it looks something like this. A prompts pops up and you can enter the value and see the result on the log.</p>
  <p><a href="https://i.stack.imgur.com/jJq6q.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jJq6q.jpg" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/YpSyz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YpSyz.jpg" alt="enter image description here" /></a></p>
  <p>How do I do this in Vs code terminal instead of going to a browser's console, run and see the result? I tried to run it for example <code>node test.js</code> in vs code terminal. Of course, it's getting an error, because <code>prompt</code> is not defined. I've seen and tried browser preview extension, but doesn't work for a simple code like this. A json script for a setting maybe or any extension that works? Thanks for your help.</p>