<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title> calculator! </title>
<link rel="stylesheet" href="bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
first number : <input type="text" name="num1" />
<br><br>
second number : <input type="text" name="num2" />
<br><br>
sum : <input type="text" name="answersum" />
<br><br>
<input type="button" name="add" value ="add" onClick="addnum()" />
<script>
(
function addnum(){
var num1 = number(document.getElementByName("num1").value);
var num2 = number(document.getElementByName("num2").value);
var sum = num1 + num2;
document.getElementByName("answersum").value = sum;
}
</script>
</body>
</html>
i would like to add two numbers using JavaScript by assigning each number to a variables. but when i click add nothings happens or is there any ways that i can add this two numbers without using a variables? thank you
Number(document.getElementsByName("num1")[0].value)and you have a weird bracket starting your script( function