How to withdraw the amount of variables on the screen using two functions?

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:
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
March 23rd 20 at 19:14
2 answers
March 23rd 20 at 19:16
Solution
var x = 1;
var y = 2;

function sum(x, y) {
 return x + y; 
}

function show() {
 document.getElementById("r").innerHTML = sum(x, y);
}

show();
March 23rd 20 at 19:18
Solution
function summa(x,y){
 return x+y; 
}
function show (){
document.getElementById("r").innerHTML=summa(1,2);
}
show();

Find more questions by tags JavaScript