As per learn and try I am working on very simple function to understand features of JavaScript function. But after create function I am getting some issues, I hope someone can help me for my following questions.
Questions are:-
a) Why console.log from browser is showing ReferenceError: c is not defined ?
b) Why p id="demo" is not able to show result ?
c) Why alert(c); outside of the function is not showing result once browser load/refresh?
d ) Why return(c); is not working?
function show(a, b){
var c = a+b;
alert(c);
console.log(c);
return(c);
}
alert(c);
document.getElementById("demo").innerHTML = c;
<p onclick="show(10, 20)" >This example calls a function which performs a calculation, and returns the result:</p>
<p id="demo"></p>