Jump to content

Can Anybody Help Me In 2 Php Problems . Both Are Given Below . Thanks


johntedu
 Share

Recommended Posts

 

 

 

3.

Given a function specialSum(x,y,z) that:

a. Returns the sum of (x, the absolute value of y, z) e.g. x+|y|+z

b. All parameters are optional

c. Always returns an integer.

What values of x, y, z, and return value are necessary to verify that this

function performs as specified in PHP? To start you out

specialSum(2+2+2)=>6 and specialSum()=>0 are two of the tests I’m looking

for. Are there any differences in Javascript?

 

5. Identify potential problems and inefficiencies with the following

Javascript, explain each problem and how you would fix it. Not all

problems are syntactic.

<script type="text/javascript">

function newObject(objectName) {

ex = "ret = new " + objectName + "();";

eval(ex);

return ret;

}

startUp = newObject('PSUtil');

if ( startUp.message != undefined ) {

document.getElementById('startMessage').value = startup.message;

}

startUp.engine = newObject(startUp.workingClass);

startUp.specialElements = givenSelectionFunction();

function wireFunction(elements ) {

for ( i=0; i < elements.length ; i ++ ) {

el = document.getElementById(elements);

for ( i=0; i < startUp.specialElements.elements.ids.length ; i++ )

{

if ( elements == startUp.specialElements.elements.ids ) {

el.onchange = startUp.specialElements.specialFunction;

}

}

for ( f in funcs ) {

el.attachEvent(f,funcs[f]);

}

}

};

wireFunctions ( startUp.engine.veryLargeArrayOfElementIDs);

function givenSelectionFunction() {

var elementArray = new Array();

working = document.getElementsByTagName('special');

for ( i=0; i<working.length; i++ ) {

var myTestFunction = function(el) {

if ( /* some complex test of el that must be in a function */) {

return true;

} else {

return false;

}

};

if (myTestFunction([working) ) {

elementArray.push(working);

}

}

return

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.