Function Requirements Activity 2 - Two Function Calls (10 mins) Response 3d asks you to describe...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 } 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 }
Expert Answer:
Answer rating: 100% (QA)
For the first function findMaxlist here are the calls and their outputs Call 1 findMax10 20 30 Cal... View the full answer
Related Book For
Introduction to Management Science A Modeling and Cases Studies Approach with Spreadsheets
ISBN: 978-0078024061
5th edition
Authors: Frederick S. Hillier, Mark S. Hillier
Posted Date:
Students also viewed these programming questions
-
The Medical Assurance Company is investigating the cost of a routine office visit to family-practice physicians in the Rochester, New York, area. The following is a list of 39 family-practice...
-
We can measure how good a center Kevin Bacon is by computing each performer's Hollywood number or average path length. The Hollywood number of Kevin Bacon is the average Bacon number of all the...
-
The following selected ratios are available for Pampered Pets Inc. for the most recent three years: Instructions (a) Calculate the average collection period and days in inventory for each year. (b)...
-
a. Separately calculate the rental cost per unit and the utilities cost per unit for both March and April. b. Identify which cost is variable and which is fixed. Complete this question by entering...
-
According to the American Veterinary Medical Association (AVMA), 38.4% of households in the United States own a dog as a pet (AVMA website). Suppose that a company that sells dog food would like to...
-
An igloo is built in the shape of a hemisphere, with an inner radius of 1.8 m and walls of compacted snow that are 0.5 m thick. On the inside of the igloo the surface heat transfer coefficient is 6...
-
You will invest $ 2 0 0 per year. If the rate is 9 . 0 8 % , how much will you have in 1 8 years?
-
On May 31, O'Hearn Limited had a cash balance per books of $13,400. The bank statement from Community Bank on that date showed a balance of $15,230. A comparison of the bank statement with the...
-
The case asks you to put yourself in the shoes of Susan Jenkins, the CFO of a web applications company called Software Associates. Your boss, software Associates' CEO, Richard Norton, is worried...
-
If you were analyzing a replacement project and you suddenly learned that the old equipment could be sold for $1,000 rather than $100, would this new information make the replacement look better or...
-
Explain this statement: Using financial leverage has both good and bad effects.
-
Why is the relevant cost of debt the interest rate on new debt, not that on already outstanding, or old, debt?
-
Why should companies use a projects free cash flows rather than accounting income when determining a projects NPV?
-
What are some factors that complicate the post-audit process?
-
Scenario: On a monthly basis prior to closing the books, the Accounting Manager performs a flux analysis on the balance sheet and profit & loss statement (P&L). For any variance greater than...
-
Create a data model for one of the processes in the end-of-chapter Exercises for Chapter 4. Explain how you would balance the data model and process model.
-
The Morton Ward Company is considering the introduction of a new product that is believed to have a 50-50 chance of being successful. One option is to try out the product in a test market, at an...
-
a. Ash decides to allocate $4 million to fund the exhibit. Given the pieces available and the specific requirements from Ash and Celeste, formulate and solve a binary integer programming problem to...
-
"This is your lucky day. You have just won a $20,000 prize. You are setting aside $8,000 for taxes and partying expenses, but you have decided to invest the other $12,000. Upon hearing this news, two...
-
How are products and services different?
-
How does the product life cycle influence marketing strategy decisions?
-
What is the difference between secondary demand and primary demand?
Study smarter with the SolutionInn App