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

Websites to create real time user conversations, Prototype-WebRTC widget fo...

Prototype-WebRTC widget for websites to create real time user conversations The project comprise a server side built using node.js and a client side widget using webRTC. Users u

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

Seeking for a programmer ajax, Seeking for a programmer We look forward ...

Seeking for a programmer We look forward to build a relationship with somebody or a group of people to work with us on our e-commerce platform. Expertise needed- • JavaScr

Need an expert to clone a website, Need an expert to Clone a website I w...

Need an expert to Clone a website I would like to repeat a website with other words to have a similar website with the same application for demo trading and trial accounts. O

I want a jquery mobile template creation expert, I am looking for a Jquery ...

I am looking for a Jquery mobile expert with strong css skills who has created Jquery ui and Jquery mobile plugins before as well as utilized other advanced java-script and CSS pro

Need help to fix virus and spam crash prevention, Need help to fix Virus an...

Need help to fix Virus and spam crash prevention Problem resurfaced with the GEG site. Site down since this morning by network solutions. Can you help us? Desired Skills are

Want professional looking table in html / css, Want Professional Looking Ta...

Want Professional Looking Table in HTML / CSS Want an experienced HTML or CSS developer to create a table which we is able to use on several web pages and that can be edited ver

How you are going to proceed to deploy the web site, Question: (a) A sm...

Question: (a) A small Mauritian enterprise specialized in the production of pickles would like to launch a web site allowing its customers to have access to its range of produc

Layout view, a. Layout View - you can build page layout, insert graphics, &...

a. Layout View - you can build page layout, insert graphics, & other media. b. Standard View - as well to insert graphics text & media, you can also add layers, create frame doc

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