There goal is to bring the sum of the variables on the screen, one function impossible to me.But I want two functions to do that one function applied to another, I need to better understand how to interact between itself. Tried to implement the two options but none is working.

first:

second:

Help to edit both options I and using the return to bring the amount on the screen and also the second option with variable sum

first:

```
function summa(){
var x=1;
var y=2;
var sum=x+y;
}
function show (){
document.getElementById("r").innerHTML=summa;
}
```

second:

```
var x=1;
var y=2;
function summa(x,y){
return=x+y;
}
function show (){
document.getElementById("r").innerHTML=summa;
}
```

Help to edit both options I and using the return to bring the amount on the screen and also the second option with variable sum

asked March 23rd 20 at 19:14

2 answers

answered on

Solution

```
var x = 1;
var y = 2;
function sum(x, y) {
return x + y;
}
function show() {
document.getElementById("r").innerHTML = sum(x, y);
}
show();
```

answered on

Solution

```
function summa(x,y){
return x+y;
}
function show (){
document.getElementById("r").innerHTML=summa(1,2);
}
show();
```

Find more questions by tags JavaScript