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 are looking for expert coldfusion programmer, We are looking for Expert ...

We are looking for Expert ColdFusion Programmer - must be in Northern VA/DC area We are in want of an expert ColdFusion developer who can help us with a project that involves ec

We need developer for modifying a website, We are looking for a very skille...

We are looking for a very skilled php developer to help us make modifications to our website. Job Description- We are looking for a Web Developer. Your responsibilities- 1

I desire help for website development, website development 1. You want t...

website development 1. You want to have ideal about different time zone at the world, instance, USA have few different time zone, Los Angeles, New York, and USA change time twic

Need help to adding new tab on the website, Need help to Adding new tab on ...

Need help to Adding new tab on the website A new tab or link needs to be created on the website for customer reviews. The customers must be able to write about their experience

We need help to develop wordpress plugin/ widget, We need help to develop W...

We need help to develop Wordpress Plugin/ Widget Need Somebody that can build a Wordpress Widget or Plugin API Develop using ruby, perl, php, java, JavaScript or python. Desi

Web design required for graphic company, Web Design A digital media as w...

Web Design A digital media as well as graphic company is seeking an individual with web experience to work with the company to update as well as manage its four web sites. De

I want one 80legs app, 80legs App, import into Wordpress I want one 80le...

80legs App, import into Wordpress I want one 80legs app. Scraps information from five different websites and imports the information into Wordpress database. Desired Skills a

I need to optimize my wordpress website, I need to optimize my wordpress we...

I need to optimize my wordpress website My website is very sluggish. Will you be capable to optimize. I have AWS S3 as well as CloudFront CDN to optimize the delivery. I want so

Need help in wordpress programming, Wordpress programming We are creativ...

Wordpress programming We are creative agency seeking a developer proficient in wordpress programming for our client, a real estate team. We need layout content by now complet

We need help in user friendly room renting website, We need help in User fr...

We need help in User friendly room renting website a) I need to develop a site similar to spareroom.co.uk in u reply include 1) site u have similar like my refer remember to inc

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