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

Font tag, HTML provides the flexibility of altering the characteristics of ...

HTML provides the flexibility of altering the characteristics of the font like size, color etc. Every browser contains a default font setting which governs the default font name, s

Need help of seo for existing website, SEO FOR EXISTING WEBSITE We are s...

SEO FOR EXISTING WEBSITE We are seeking an expert who will do the SEO for an existing website. The website is hosted in a third party server not ours. The client wants his websi

I need help in rv storage, I need help in RV Storage Knowledge as well a...

I need help in RV Storage Knowledge as well as previous experience programming checkout fees between Interchange and Processor companies. Job Description- We're seeking a Web

Internet service providers, As specified earlier, nobody truly owns the Int...

As specified earlier, nobody truly owns the Internet, although it is maintained through a group of volunteers interested in supporting this mode of information interchange. Central

Web and mobile interface for the workforce, Web and Mobile Interface for th...

Web and Mobile Interface for the Workforce MyEma is an innovative online interface paired with a slick as well as easy to use application. The key objectives of this project are

Advanced html, HTML is built up of many elements, lot of which is overlooke...

HTML is built up of many elements, lot of which is overlooked. Even though you can create a Website with the fundamental knowledge of HTML, to take benefit of many of the advanced

Hootesuite stream clone need help in this, Hootesuite Stream Clone We ne...

Hootesuite Stream Clone We need for a clone of the 'Streams' tab a) We must be able to add multiple search streams side by side. b) When the page is closed the search stre

Need help in install wordpress from back-up, Install Wordpress from back-up...

Install Wordpress from back-up I have my back-up for my Wordpress. I want someone who can fix this as well as put my website back online. Desired Skills are MySQL Administrat

Wordpress plugin for capture vehicle photos, Wordpress Plugin Capture Vehic...

Wordpress Plugin Capture Vehicle Photos and description create video, submit to YouTube Project Description: I want to prepare a web based automated software program that wil

Dreamweaver, A Web site is a set of linked documents along shared attribute...

A Web site is a set of linked documents along shared attributes, such as associated topics, a similar design, or a shared reason. Macromedia Dreamweaver is site creation & manageme

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