0

Add two num in JavaScript

<!doctype html> <html> <head> <script> function add(){ var a,b,c; a=Number(document.getElementById("first").value); b=Number(document.getElementById("second").value); c= a + b; document.getElementById("answer").value= c; } </script> </head> <body> Enter the First number : <input id="first"> Enter the Second number: <input id="second"> <button onclick="add()">Add</button> <input id="answer"> </body> </html>

21st Oct 2018, 5:02 AM
Manoj Yadav
Manoj Yadav - avatar
2 ответов
0
What's your question regarding that code? Please clarify. The only errors I see in that code snippet right now is that you didn't declare the input types.
21st Oct 2018, 5:13 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar