Returning a value, PHP Web Programming

Assignment Help:

Another function of a function is to return a value. Imagine we have the following function:

<HTML>

<HEAD>

<TITLE>IGNOU </TITLE>

<SCRIPT Language = "JavaScript">

function calculate(a,b,c)

{

d = (a+b) * c;

return d;

}

</SCRIPT>

</HEAD>

<BODY>

<SCRIPT Language = "JavaScript">

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

alert('calculate(4,5,9) = ' +x + ' and ' + ' calculate((x/3),3,5) = ' + y);

</SCRIPT>

</BODY>

</HTML>

 

322_Returning a value.png

Figure:  Using a Function that Returns a Value

The function illustrated in Figure calculates a number from the numbers you pass to it. While this is done it returns the result of the calculation. The function passes the result back to the function which called it. While the function executes return statement, control goes back to the calling program without executing any more code in function, if there is any.

The calling of the function is done via the following two statements in the figure:

var x = calculate(4,5,9);

var y = calculate((x/3),3,5);

This means that you have declared variable x and are telling JavaScript to execute calculate ( ) along the arguments 4, 5 & 9 and to put the returned value (81) in x. After that you declare a variable y and execute calculate ( ) again. The first argument is x/3, which means 81/3 = 27, thus y becomes 150.Certainly you can also return strings or even Boolean values (true or false). While using JavaScript in forms, you can write a function which returns either false or true and therefore tells the browser whether to submit form or not.


Related Discussions:- Returning a value

Need web engineer for revolutionary digital media startup, Looking for a we...

Looking for a web engineer to join revolutionary digital media startup We are shifting the way the world publishes, promotes and consumes video. Want to aid us? We delivers c

Need capable to design any required worpress plugin, Wordpress Web designer...

Wordpress Web designer/Developer with web application development skills Be capable to design any required Worpress plugin, component, modules. We are begin a new USMLE/COMLE

Need help to edits to zen cart website, Edits to our Zen Cart website We...

Edits to our Zen Cart website We would like to rental a developer to make the following adjustments to our Zen Cart 1.5.x online store 1) Featured Products on Main Page Ha

I want help for it developer, I want help for IT Developer needed - Benelux...

I want help for IT Developer needed - Benelux Region We are seeking an experienced web developer with the following skills 1) Front-end development (HTML5/CSS3) 2) Front-end

Qualified django and python expert needed, Qualified Django and Python Expe...

Qualified Django and Python Expert to make certain site changes We want somebody to change the settings therefore that we can have a different template for the homepage. We like

I want a simple joomla website built, I want a simple Joomla website built ...

I want a simple Joomla website built I want a developer/development team to build me a simple Joomla website with a custom design. The design will be copied EXACTLY from my curr

Need help -real estate website and mobile apps ios & android, Real Estate W...

Real Estate Website and Mobile apps(iOS & Android) High Level Project Description I am seeking to create user friendly mobile responsive Real Estate website as well as Mobile

We are in search of a web developer., Web & wordpress theme : design & deve...

Web & wordpress theme : design & development Expert with php, bootstrap, css and JavaScript. Good with HTML5 will be nice. Able to work with job schedule Job Description- We'

Need help in revisions to expression engine website, Revisions to Expressio...

Revisions to Expression Engine website I am handling a website created from Expression Engine framework and need a few revisions completed. I will attempt to describe the revisi

What is pear in php, What is PEAR in php? PEAR (PHP Extension and Appli...

What is PEAR in php? PEAR (PHP Extension and Application Repository) is a framework and repository for reusable PHP components. PEAR is a code repository comprising all kinds o

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd