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

We want a magento installation and optimization, We want a Magento installa...

We want a Magento installation and optimization We want to have our Magento store installed on a server as well as we need some work done in terms of speed optimization / cachin

Database authorization, Use a database table Authorization as shown below...

Use a database table Authorization as shown below with appropriate choice of data types .  This table must be populated by you manually using the PhpMyAdmin interface to MySQL.

I am looking for a programmer who can implement my mockups, BigCommerce ful...

BigCommerce fully responsive design implementation I am looking for a programmer who can implement my Mockups on my BigCommerce shop. Requirement- a) You write clean code

We need help in couponic customzation, We need help in COUPONIC CUSTOMZATIO...

We need help in COUPONIC CUSTOMZATION Need Customization of cuponic script with added modular functionality. I have purchased the script as well as the modules. The customizatio

Likenet upgrade want help in urgent, LikeNet Upgrade - Earn prizes Liken...

LikeNet Upgrade - Earn prizes Likenet Upgrade - Earning Prizes Aptitude to set goals example get 1000 credits in 10 days To get a prize get a bonus 1000 credits or get an

Need help in chrome extension for site, Chrome extension I am seeking a ...

Chrome extension I am seeking a chrome extension for amazon.com. The extension will make it relaxed for me to get in touch with customers that have left me a feedback. Have you

We need website developer, Website Developer We are currently looking fo...

Website Developer We are currently looking for a web site developer. Job Description- We're looking for a Web Developer. Your responsibilities- a) Review business re

Checkbox element, Use a checkbox element (not a radio button/s). Refer to ...

Use a checkbox element (not a radio button/s). Refer to IT 202 manual but look up on the Internet how to define this in HTML and then how it can then be tested to guide decision-m

Iframe, is an HTML 4.0 addition to the frames toolbox. Now only MSIE suppor...

is an HTML 4.0 addition to the frames toolbox. Now only MSIE supports . Unlike frames created via & , d

We need a front end developer for responsive site, We need a Front End Deve...

We need a Front End Developer for responsive site In search of a front end developer to put together a responsive template (using Zurb Foundation or alternative) for a modern, s

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