0
I’m making a simple calculator with Javacript and when I type the values in input
they are grouped and not summed up what I am doing wrong? follows the code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<input type="text">
<input type="text">
<button type="text">calcular</button>
<p></p>
<script>
var input1 = window.document.querySelectorAll("input")[0];
var input2 = window.document.querySelectorAll("input")[1];
var button = window.document.querySelector("button");
button.addEventListener("click", function() {
window.document.querySelector("p").textContent = input1.value + input2.value;
});
</script>
</body>
</html>