You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//a). Define an anonymous function and set it equal to a variable with a normal, non-suspicious name. The function takes one parameter. This will be the fuel level on the shuttle.
//c). The cargo hold has better security than the fuel tanks. It counts how many things are in storage. You need to replace what you steal with something worthless. The count MUST stay the same, or you’ll get caught and thrown into the LaunchCode brig.
46
59
47
60
//d). Don’t get hasty, matey! Remember to test your function.
61
+
letfakeCargo=['football pads','silver chain'];
62
+
stolenCargo=[];
63
+
64
+
letcheckForBomb=function(arr){
65
+
if(typeofarr==='object'){
66
+
stolenCargo=arr.splice(3,2);
67
+
returnarr.concat(fakeCargo);
68
+
}else{
69
+
returnarr;
70
+
}
71
+
}
72
+
73
+
console.log(checkForBomb(cargoHold));
74
+
console.log(stolenCargo);
75
+
48
76
49
77
/* Finally, you need to print a receipt for the accountant. Don’t laugh! That genius knows MATH and saves us more gold than you can imagine.
50
-
*/
78
+
*/
51
79
52
80
//a). Define a function called irs that can take fuelLevel and cargoHold as arguments.
53
81
54
82
//b). Call your anonymous fuel and cargo functions from within irs.
55
83
56
84
//c). Use a template literal to return, "Raided _____ kg of fuel from the tanks, and stole ____ and ____ from the cargo hold."
57
85
86
+
letirs=function(levelOfFuel,itemsInCargo){
87
+
letarr=checkForBomb(itemsInCargo);
88
+
letarr2=checkForCleanFuel(levelOfFuel);
89
+
return`Raided ${checkForCleanFuel(fuelLevel)} kg of fuel from the tanks, and stole ${stolenCargo[0]} and ${stolenCargo[1]} from the cargo hold.`
0 commit comments