<!DOCTYPE html>
<html>
<head>
<title>Return statement in javascript function </title>
<meta charset="utf-8" />
</head>
<body>
<script>
function addition(n1,n2)
{
var total = n1 + n2;
return total;
}
var res = addition(6, 5);
document.write("addtion of two number:" + res);
</script>
</body>
</html>
Out put : addtion of two number:11
.............................................................................User insert a value ..................................
<!DOCTYPE html>
<html>
<head>
<title>Return statement in javascript function </title>
<meta charset="utf-8" />
</head>
<body>
<script>
var a = parseInt(prompt("Enter first number"));
var b = parseInt(prompt("Enter Second number"));
function addition(n1,n2)
{
var total = n1 + n2;
return total;
}
//var res = addition(6, 5);
var res = addition(a, b);
document.write("addtion of two number:" + res);
</script>
</body>
</html>
No comments:
Post a Comment