Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the javascript code. After the code are the tasks that need to be added to this code. This is my third attempt before

Here is the javascript code. After the code are the tasks that need to be added to this code. This is my third attempt before i just give up trying to get help with this problem.

function checkFuel(level) {

if (level > 100000){

return 'green';

} else if (level > 50000){

return 'yellow';

} else {

return 'red';

}

}

function holdStatus(arr){

if (arr.length < 7) {

return `Spaces available: ${7-arr.length}.`;

} else if (arr.length > 7){

return `Over capacity by ${arr.length-7} items.`;

} else {

return "Full";

}

}

let fuelLevel = 200000;

let cargoHold = ['meal kits', 'space suits', 'first-aid kit', 'satellite', 'gold', 'water', 'AE-35 unit'];

console.log("Fuel level: " + checkFuel(fuelLevel));

console.log("Hold status: " + holdStatus(cargoHold));

Here is what needs to be added to the code above:

First, steal some fuel from the shuttle.

  1. Define an anonymous function and set it equal ter a variable with the normal, non-suspicious name of parrotFood. The function needs one parameter, which will be the fuel level on the shuttle.
  2. Ye must siphon off fuel without alerting the TAs. Inside yer function, ye want to reduce the fuel level as much as possible WITHOUT changing the color returned by the checkFuel function.
  3. Once ye figure out how much fuel ter pump out, return that value.
  4. Be sure to test yer function! Those bilge rat TAs will notice if they lose too much fuel.

Next, liberate some of that glorious cargo.

  1. Define another anonymous function with an array as a parametarrrrr, and set it equal to another innocent variable, deckMops.
  2. Ye need to swipe two items from the cargo hold. Choose well. Stealing water ain't gonna get us rich. Look fer smaller tech or valuable items that we kin sell like ['dilithium', 'gold', 'AE-35 unit', 'Legos', 'TI-89 calculator'].
  3. Put the swag into a new array and return it from the function.
  4. The cargo hold has better security than the fuel tanks. It counts how many things are in storage. Ye need to replace what ye steal with something worthless. The count MUST stay the same, or ye'll get caught and thrown into the LaunchCode brig.
  5. Don't get hasty, swabbie! Remember to test yer function.

Finally, ye need to print a receipt for the accountant.

Don't laugh! That genius knows MATH and saves us more gold than ye can imagine.

Define a function called irs that takes fuelLevel and cargoHold as parametarrrrrs.

  1. Call parrotFood and deckMops from within irs.
  2. Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold."

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions