johntedu Posted November 25, 2012 Share Posted November 25, 2012 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 https://forums.phpfreaks.com/topic/271132-can-anybody-help-me-in-2-php-problems-both-are-given-below-thanks/ Share on other sites More sharing options...
Pikachu2000 Posted November 25, 2012 Share Posted November 25, 2012 You seem to have misconceptions as to the purpose of a help forum. We aren't here to do your homework. Link to comment https://forums.phpfreaks.com/topic/271132-can-anybody-help-me-in-2-php-problems-both-are-given-below-thanks/#findComment-1394905 Share on other sites More sharing options...
Recommended Posts