how can i log my sum using the function below?

Assuming that firstNum and secondNum are input fields you would need to get the value of these inputs. Input values are string so you also would need to cast the values to numbers.

var result = document.getElementById('result');
var firstNum = document.getElementById('number1');
var secondNum = document.getElementById('number2');

firstNum.addEventListener('keyup', sum);
secondNum.addEventListener('keyup', sum);

function sum(e){

    var mySum = Number(firstNum.value) + Number(secondNum.value);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top