I have been teaching myself some Javascript; and I am having trouble getting this function to run properly. This is what is being output.
Answer: [object HTMLInputElement][object HTMLInputElement]
function addNumbers() {
  var firstNum = document.getElementById("num1");
  var secondNum = document.getElementById("num2");
  result = firstNum + secondNum;
  document.getElementById("demo").innerHTML = "Answer: " + result;
  return result;
}<!DOCTYPE html>
<html>
<head>
  <!--            ,<script src="scripts.js"></script> -->
</head>
<body>
  <h2>JavaScript Functions</h2>
  <p>This example calls a function which performs a calculation and returns the result:</p>
  <form>
    First Number<br>
    <input type="text" name="firstNum" id="num1"><br> Second Number<br>
    <input type="text" name="secondNum" id="num2"><br>
    <input type="button" value="Add!" onclick="addNumbers()">
  </form>
  <p id="demo"></p>
</body>
</html>


var firstNum = document.getElementById("num1").valuedocument.getElementByIdreturns a node. If you want the content of it, you'll need to extract the value.document.getElementById("num2")you are selecting the element with idnum2and not it's value.Number(firstNum) + Number(secondNum)