How are html id attributes passed as an argument to a separate JavaScript file?
<p>I'm still new to programming. I've followed a tutorial for a JavaScript calculator online, and in this tutorial html id attributes are passed along to a separate JavaScript file. The file is passed as such:</p>

<pre><code>&lt;script src="logic.js"&gt;&lt;/script&gt;
</code></pre>

<p>Here is an example:</p>

<pre><code>var box = document.getElementById('display');

function addToScreen(x){
  box.value += x;

if (x == 'c') {
  box.value = ' ';
  }
}
</code></pre>

<p>Where the box variable is the empty field in a calculator where integers and operations are entered into (the 'c' is the button to clear the calculator). The function addToScreen has the parameter x, and x gets to be an input such as the number 9, which is entered with the following input:</p>

<pre><code>&lt;input type ="button" value="9" id="keys" onclick="addtoscreen('9')"&gt;
</code></pre>

<p>I'm trying to understand how these are passed more, so I'm playing with them. I have made a separate html and JavaScript file, and there are three input fields for the user to input numbers into, and a button to click to average the three numbers:</p>

<pre><code>&lt;form&gt;
&lt;input type="number" id="first"&gt; &lt;br&gt;
&lt;input type="number" id="second"&gt;&lt;br&gt;
&lt;input type="number" id="third"&gt;&lt;br&gt;

Result: 
&lt;input type="text" id="avgResult" disabled="true"&gt; &lt;br&gt;
&lt;input type="button" value="average" onclick="average()"&gt;&lt;br&gt;
&lt;/form&gt;

&lt;script src="logic.js"&gt;&lt;/script&gt;
</code></pre>

<p>And the JavaScript file named logic.js has:</p>

<pre><code>ar avgResult = document.getElementById("avgResult");

function average(a, b, c) {
  a = Number(document.getElementById("first"));
  b = Number(document.getElementById("second"));
  c = Number(document.getElementById("third"));
  avgResult.value = ((a + b + c) / 3);
}
</code></pre>

<p>Whatever combination of numbers I enter only results in NaN. I thought it would be useful to use the Number() method to convert any string to a number (I originally had the input tag's attribute set to "text", as opposed to "number".</p>

<p>Any advice or direction pointing would be very helpful. Thank you!</p>