Basically I am trying to create a website that takes in two input numbers and displays the sum of the two numbers. For some reason though, it only seems to be displaying NaN in the output div? What am I doing wrong here? (Ignore the other aspects of the page.)
Hello @lloydtechno58
hope that everything going fine with you
i just see a miss type in your code
in your queryselector you write (βinput1β) which it should be (β.input1β) as it class selector
check this link
when you get error in js file try to use the console to log the value then keep add console log to the function or part of code that participate in calculation to that code so it help you debug the cause of the issue
hope that help and have a nice day
Thanks a lot for the advice and my program is sort of working
you very welcome and glad it worked
Im still having some problems. I changed up my code but it still isnt working.
For some reason, the sum variable doesnt equal to anything hence its not appearing in the output:
i know js sometime show forgivness about missing semicolon but i recommend that you do not relay on that
there many missing semicolon so add them and then add console.log(input1);
to check if it retrive the value or not
i think the issue with the semicolon
if it did not work could you share your code in any service like https://jsfiddle.net/ or https://codepen.io/
it will be easier for me to edit the code and debug it
hope that help and have a nice day
I finally did it! I just had to retrive the value of the inputs when the function iterates. That way my variable gets updated every time the function is run.
Thanks for taking your time to help me out !
well done and you welcome