J's Rhapsody

[Javascript]문제 1.3: Using Function Expressions with Parameters 본문

IT/JAVASCRIPT

[Javascript]문제 1.3: Using Function Expressions with Parameters

J's Rhapsody 2018. 1. 11. 13:01

Using Function Expressions with Parameters

The devs at the Death-Defying Dogwoods have determined a specific formula for the quantifiable amount of fear generated at the theme park. Their formula is based on the amount of people, the amount of rain, and the amount of sharks. Yes. Sharks.

var fearGenerated = function(numPeeps, rainInInches, numSharks) {
  var rainFear = numPeeps * rainInInches;
  var sharkFear = numSharks * numSharks * numSharks;
  var totalFear = sharkFear + rainFear;
  return totalFear;
};
  1. Analyze the fearGenerated formula.
  2. Assign appropriate values to the peoplerain, and sharks variables so that the amount of fear generated will be no less than 100, but no more than 400.
  3. Call the fearGenerated function and pass in the variables as arguments.
  4. Store the result of that function in a new variable called fear.

Note: You do not need to change the existing fearGenerated function.


1
2
3
4
5
6
7
8
9
10
11
12
var people = 100;
var rain = 2;
var sharks = 3;
 
var fearGenerated = function(numPeeps, rainInInches, numSharks) {
  var rainFear = numPeeps * rainInInches;
  var sharkFear = numSharks * numSharks * numSharks;
  var totalFear = sharkFear + rainFear;
  return totalFear;
};
 
var fear = fearGenerated(people, rain, sharks);
cs



Comments