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
-
Part 1 (15pts) In this exercise, you'll add code to an Inventory Maintenance application that reads data from and writes data to an XML file. 1. Open the InventoryMaintenance With XML File directory,...
-
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...
-
How's the weather? The following table presents the daily high temperatures for the city of Macon, Georgia, in degrees Farenheit, for the winter months of January and February in a recent year. 65 48...
-
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...
-
At the beginning of the current period, Azim Enterprises Ltd. had balances in Accounts Receivable of $2.1 million and in Allowance for Doubtful Accounts of $144,000 (credit). During the period, Azim...
-
What are the potentially negative impacts a borrower may experience because of the interest-only payments and variable interest rates associated with a HELOC?
-
In the cosmetics industry, sales promotions reign supreme. You manufacture and market organic skin creams, which are sold nationwide at your own boutiques inside various department stores. You are...
-
First Bank has some question as to the tax-free nature of $5 million of its municipal bond portfolio. This amount is excluded from First Bank's taxable income of $55 million. Management has...
-
Could someone please step-by-step explain how we interpret this and answer it? I have a teacher that isn't very helpful. Thank you. Using the shift or stretch theorem find the Fourier transform of...
-
The idealized cross-section of a two-cell thin-walled wing box is shown below with the data in Table 22.7. If the wing box supports a load of 44,500 N acting along web 25, calculate the shear flow...
-
An organization may be following the necessary steps to ensure security, to include building security and risk management programs, training staff, and performing data protection. How can management...
-
1 Coulomb (C) = 6.25 x 108 electrons k 8.99 x109 Nm/C 1. (a) A solid metal sphere has an excess of 3.75 x 1016 electrons. What is the net charge on this ball in Coulombs? (b) A net charge of 965 will...
-
SITUATION#1: Given the beam loaded as shown below. Assuming El to be constant, solve the following: 10 KN 1 m 1 m TTTT A) Location of maximum deflection. B) Magnitude (value) of the maximum...
-
On October 1, 2021 Chicago Towers reached an agreement to rent the first floor space to Bailey's Steakhouse. The previous tenant also used the space as a restaurant but closed within 6 months of...
-
3. How does the transfer price (i.e., royalty payments) influence an evaluation of the performance (i.e., profitability) of Digital Creations? What could (or should) VGE do with Digital Creations if...
-
Discuss the advanced computational techniques utilized in geotechnical engineering for modeling soil-structure interaction and predicting ground response under various loading conditions .
-
Table 1. Selected Characteristics of Studies Comparing Treatment with Antidepressant Medication to Combined Treatment with Psychotherapy and Medication Study Disorder Psychotherapy Medication Ncom...
-
[a] Two foam blocks, each with a charge of 19 micro coulombs (1 C = 10-6 C), are both held in place 19 cm apart in the east-west direction. A foam ball with a charge 49 C is placed 55 cm north of the...
-
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...
-
What is the necessary condition for a share buyback to increase earnings per share? to increase the book value of equity capital per share?
-
In what circumstances does a company have good reason to have a capital decrease?
-
Forgetting tax considerations, can a capital decrease enhance the value of the companys operating assets? the value of its shares?
Study smarter with the SolutionInn App