Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Function Requirements Activity 2 - Two Function Calls (10 mins) Response 3d asks you to describe two different calls to the same function with
Function Requirements Activity 2 - Two Function Calls (10 mins) Response 3d asks you to describe two different calls to the same function with different arguments that cause the function to run differently. For this activity you should: Write out two different calls to the function listed on the left with different arguments. For example findMax ([2,3,4]) and find Max ([10,20,30]) Describe the specific line of code that will run differently based on the different inputs List what the output of each function call will be // This function finds the maximum value in // a list and returns it. 01 function findMax(list){ for (var i = 0; i < list.length; i++){ if(list[i] > max) { max= list[i]; 02 var max = list[0]; 03 04 05 06 } 07 Call 1: findMax([10, 20, 30]); Call 2: find Max([5, 3, 4]); Which condition runs differently: Result of Call 1: Result of Call 2: 08 09 } } return max; // This function checks if the game is over Call 1: checkEndGame(80); // If the score is more than 100 then it hides // all the enemies and runs the endGame function Call 2:checkEndGame(120); // that shows your final score. 01 function checkEndGame (score){ if (score >100) { 02 for(var i = Which condition runs differently: Result of Call 1: 03 0; i < 3; i++){ 04 setProperty("enemy "+i, "hidden", true); Result of Call 2: 05 } 06 endGame(); 07 } 08 }
Step by Step Solution
★★★★★
3.41 Rating (145 Votes )
There are 3 Steps involved in it
Step: 1
For the first function findMaxlist here are the calls and their outputs Call 1 findMax10 20 30 Cal...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started