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

Customize a oxyclassified website, Customize a oxyclassified website Pro...

Customize a oxyclassified website Project Description: i have being working with this site for a while but i just found out a few thing that i would like to change. it is

Need help to wordpress classipress theme customization, Wordpress Classipre...

Wordpress Classipress theme customization We are seeking a Wordpress customisation expert who can adapt our original design into Classipress theme keeping the exact same feature

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

We are in need of classics24, We are in need of Classics24 We would like...

We are in need of Classics24 We would like our existing project to be entirely rewritten from scratch We have numerous websites running on 1 database in the classic car adver

We need to create a localization tool to organise multiple, We need to crea...

We need to create a localization tool to organise multiple planning The web based tool must do the follow Import excel sheet where you have a list of n events with at least t

Design and create a php document, All functionality required for this assig...

All functionality required for this assignment must be achieved using PHP server side scripting. No browser side scripting is to be used. In assignment you created the initial u

We need to migration of our site to magento, We need to Migration of our si...

We need to Migration of our site to Magento (from Zen Cart) I work as a consultant and am currently converting one of my clients e-commerce stores from Zen Cart to Magento. W

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 someone to code for website, We need someone to code for website ...

We need someone to code for website Looking for someone to work on his website via team viewer Need to be expert in Following skills: a) C# b) AJAX c) LINQ to SQL

Implement wordpress design in my existing site, Implement wordpress design ...

Implement wordpress design in my existing site Project Description: Hello i want a design for my current website. This WordPress design require implement Skills requ

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