Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions tutorials/07-functions/functions-intro/exercises/practice.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,23 @@

/** EXERCISE 1: THE WELCOME PROTOCOL **/

function greetCrew() {
console.log("Welcome back, Captain.");
}

greetCrew();

/*
TODO: Declare a function named 'greetCrew'. Inside the function,
log "Welcome back, Captain." to the console.
TODO: Declare a function named 'greetCrew'. Inside the function, log "Welcome back, Captain." to the console.
Then, invoke the function once below its declaration.
*/

/** EXERCISE 2: LIFE SUPPORT BOOST **/

/*
function activeOxygenBoost() {
console.log("Pumping extra oxygen into sectors A-D... Done.");
}

/*
TODO: Declare a function named 'activateOxygenBoost'.
Inside, log "Pumping extra oxygen into sectors A-D... Done."
Do not call it yet.
Expand All @@ -25,6 +33,14 @@

let crewIsSleepy = true;

function activateOxygenBoost() {
console.log("Pumping extra oxygen into sectors A-D... Done.");
}

if (crewIsSleepy === true) {
activateOxygenBoost();
}

/*
TODO: Create an 'if' statement that checks if 'crewIsSleepy'
is true. If it is, invoke the 'activateOxygenBoost' function
Expand All @@ -40,6 +56,8 @@ function startEngines() {
function clearLaunchPad() {
console.log("Launch pad: CLEARED.");
}
clearLaunchPad();
startEngines();

/*
TODO: Call 'clearLaunchPad' first, and then call 'startEngines'
Expand Down