Skip to content

Commit 4da52df

Browse files
committed
corrected mistakes
1 parent 15d03b1 commit 4da52df

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

more-on-functions/exercises/raid-a-shuttle.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ console.log("Hold status: " + holdStatus(cargoHold));
4141
//c). Once you figure out how much fuel to pump out, return that value.
4242

4343
//d). Decide where to best place your function call to gather our new fuel.
44-
let nonSuspiciousFunction = function (a) {
44+
let stealFuel = function (a) {
4545
if (checkFuel(a) === "green") {
4646
return a - 100001;
4747
} else if (checkFuel(a) === "yellow") {
@@ -51,7 +51,7 @@ let nonSuspiciousFunction = function (a) {
5151
}
5252
};
5353

54-
fuelLevel = nonSuspiciousFunction(fuelLevel);
54+
fuelLevel = stealFuel(fuelLevel);
5555
//placed above at line 23
5656

5757
// Next, liberate some of that glorious cargo.
@@ -92,25 +92,24 @@ console.log("Cargo hold after theft:", cargoHold);
9292

9393
//c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold."
9494

95-
let irs = function (fuelLevel, cargoHold) {
96-
let stealFuel = function (level) {
95+
function irs(fuelLevel, cargoHold) {
96+
function stealFuel(level) {
9797
if (checkFuel(level) === "green") {
9898
return level - 100001;
9999
} else if (checkFuel(level) === "yellow") {
100100
return level - 50001;
101101
} else {
102102
return level;
103103
}
104-
};
105-
};
106-
let stolenFuel = stealFuel(fuelLevel);
104+
}
105+
}
106+
let originalFuelLevel = fuelLevel;
107+
fuelLevel = stealFuel(fuelLevel);
108+
let stolenFuel = originalFuelLevel - fuelLevel;
109+
107110
let stolenCargo = stealFromCargoHold(cargoHold);
108111

109-
let receipt = `Raided ${
110-
fuelLevel - stolenFuel
111-
} kg of fuel from the tanks, and stole ${stolenCargo[0]} and ${
112-
stolenCargo[1]
113-
} from the cargo hold.`;
112+
let receipt = `Raided ${stolenFuel} kg of fuel from the tanks, and stole ${stolenCargo[0]} and ${stolenCargo[1]} from the cargo hold.`;
114113

115114
return receipt;
116115

0 commit comments

Comments
 (0)