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

Create a web page that allow students to use external files, The purpose of...

The purpose of this exericse is to allow students to practice using external files in support of web applications. For this exercise, imagine that the Batty League Flea Market acce

We need help for car transports portal, We need help for car transports por...

We need help for car transports portal I am in search of a web programmer who can realize my ideas on web. I need to create a portal for transportation in Europe especially f

I want to develop a discussion board and classifieds, I want to develop a D...

I want to develop a Discussion Board/Classifieds I'm seeking to create a discussion board/classifieds for the community I live in I do like to know what platform you'd use an

Develop a basic html page, Develop your Bio-Data in HTML Page. ...

Develop your Bio-Data in HTML Page. Qualifications &

Need help in image recognition software - opencv, Need help in Image Recogn...

Need help in Image Recognition Software - OpenCV Prototype Image Recognition service - focusing on brand/logo recognition plus objects - such as TV's Coffee Cups and so on. D

Need help in a rent a snow scooter site, Rent a snow scooter site I need...

Rent a snow scooter site I need an html/css and php developer for a project of snow scooter rental site. Entirely graphical design of subpages will be provided. I only want a pr

Need help to fix cs-cart custom printing of tickets, CS-Cart Custom Printin...

CS-Cart Custom Printing of Tickets We have a cart run on CS-Cart. The shopping cart doesn't purchase items however purchases raffle tickets. What I want is after each order is p

Resume parser, how can we parse resumes in different formats like doc,docx,...

how can we parse resumes in different formats like doc,docx,pdf and rtf ?

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