Is it possible to write a variable stored in a function of a .js file in the body of the index.html?
For example I want to put below the form of the calculator "The result of the subtraction is (and here call the variable" result "stored in the calcula_restart function of the .js file)"
function calcula_resta(){
var numero1 = document.getElementById("numero1").value;
var numero2 = document.getElementById("numero2").value;
var resultado = (numero1 - numero2);
alert ("El resultado es : " + resultado);
}
<html>
<head></head>
<script type="text/javascript" src="index.js"></script>
<body>
<form>
<p>
<b>Calculadora Resta</b>
<br/><br/>
</p>
Numero1
<br/>
<input id="numero1" type="number" />
<br/><br/>
Numero2
<br/>
<input id="numero2" type="number" />
<br/><br/>
<input type="button" value="Calcular" onclick="calcula_resta()" /><br/>
</form>
<div id= "resultado">
<!-- "EL RESULTADO DE LA RESTA ES + resultado() !-->
</div>
</body>
</html>