title: Sending GET with parameters to HTTP server
body: <p>I'm trying out the code basics and want to write some basic client-server app.
  I have an HTML page where user inputs two numbers (<code>num1</code> and <code>num2</code>) then it passes to JS which passes it to HTTP server written with NodeJS. On the server the numbers should be added and returned to the HTML page. But the server returns this error:</p>
  
  <blockquote>
    <p>ReferenceError: num1 is not defined</p>
  </blockquote>
  
  <p>What is wrong with the code?</p>
  
  <p>Here is the JS code:</p>
  
  <pre><code>function myFunction(num1, num2) {
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        num1 = Math.floor(num1);
        num2 = Math.floor(num2);
        document.getElementById("result").innerHTML = this.responseText;
      }
    };
  
    xhttp.open("GET", "http://localhost:8080?num1=2&amp;num2=3", true);
    xhttp.send();
  }
  </code></pre>
  
  <p>And here is the NodeJS code:</p>
  
  <pre><code>var http = require('http');
  
  http.createServer(function (req, res) {
    var resnum = 2 + req.params(num1) + req.params(num2);
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.write(resnum);
    res.end();
  }).listen(8080);
  </code></pre>