How can I show the result of the following function in an <div>
and not in an alert.
<script>
function suma (a,b){
var sum = a+b;
alert(sum);
};
suma(3,4);
</script>
How can I show the result of the following function in an <div>
and not in an alert.
<script>
function suma (a,b){
var sum = a+b;
alert(sum);
};
suma(3,4);
</script>
You could use the
getElementById
to assign the value of the sumYou can use javascript's innerHTML for example: