Question
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.
- 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.
- 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.
- Once ye figure out how much fuel ter pump out, return that value.
- 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.
- Define another anonymous function with an array as a parametarrrrr, and set it equal to another innocent variable, deckMops.
- 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'].
- Put the swag into a new array and return it from the function.
- 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.
- 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.
- Call parrotFood and deckMops from within irs.
- 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
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