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

Frames inside other frames, Here we will discuss how to divide frames into ...

Here we will discuss how to divide frames into distinct frames that means how to put horizontal frames in a vertical one & vice-versa. Here we will divide a frame in half horizonta

Implementing a multi-tenant configuration in moodle, Moodle integration ...

Moodle integration We have developed a web site with joomla that proposals to our clients different services. One service we are now realising is to integrate our joomla site

We want a coder for magento, Magento 2 installation We want a coder that...

Magento 2 installation We want a coder that has already installed the last Magento 2 installation Zip file so can help us to understand how to do it on our server. Desired Sk

Need help in referral program magento enterprise extension, Referral Progra...

Referral Program Magento Enterprise Extension We're seeking someone to develop a referral extension for our online jewelry store Required functionality: a) Members will ap

Zoho crm php task, Zoho CRM php task I want a coder to code a script tha...

Zoho CRM php task I want a coder to code a script that uses the Zoho CRM API. I want all the methods, accounts, cases, lead and so on. Manageable by a function or class. Desi

Quick debug of async is loading with yepnope, Quick debug of async is loadi...

Quick debug of async is loading with yepnope We are seeing several weird behaviour with our yepnope implementation where resources are being loaded a lot of times. We want someo

Work in standard view, For laying out Web pages, Layout view is helpful. Th...

For laying out Web pages, Layout view is helpful. Though you can adjust most of your design elements in Layout view, certain modification should be completed in Standard view. Whil

We want help in wordpress plugin development, We want help in WordPress Plu...

We want help in WordPress Plugin Development - Route Delivery Schedule We want a plugin that has the ability to display Delivery Schedules based on a location filter in a calend

Bigcommerce entirely responsive design application, BigCommerce entirely re...

BigCommerce entirely responsive design application I am in search of a programmer who can implement my Mockups on my BigCommerce shop. Requirement a) You write clean code wit

Flex/flash/video streaming/wowza/php developers wanted, Flex/Flash/Video St...

Flex/Flash/Video Streaming/Wowza/PHP Developers Wanted Our company is in search of a couple of developers to join our team. We are a video streaming platform alike to Ustream.tv

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