Q:

Value returning 0 or NaN instead of actual result

Just trying to make a simple weight converter program, but the result keeps giving me NaN or 0. I have coded a similar calculator using basically the same function and it works fine, I'm not sure what I am missing here.
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="weight.js"></script>
    <title>Weight Converter</title>
</head>
<body>

    <div>
        <input id="pounds" type="text" placeholder="Enter weight in pounds"/>
        <input type="button" value="convert" onclick="calc()"/>
    </div>

</body>
</html>

JS:
var k = document.getElementById('pounds').value;

function calc(){
    var result = (k / 2.2);
    alert(result + " kilograms");
    console.log(result);
}

A:

You're trying to get the .value before the onclick has been triggered. On page load, the value of the element is an empty string. Try getting the value after the click, not before:

function calc() {
  var k = document.getElementById('pounds').value;
  var result = (k / 2.2);
  alert(result + " kilograms");
  console.log(result);
}
<div>
  <input id="pounds" type="text" placeholder="Enter weight in pounds" />
  <input type="button" value="convert" onclick="calc()" />
</div>

