level_2_auth.js
/* Welcome back, Anna. Complete the logic block below to execute Level 2. */
// PROMPT: Would you like to go on a second date?
function initiateDate(annaAnswer) {
if (annaAnswer === "
") {
return selectDate();
} else {
return "Throw Error";
}
}
Documentation: If / Else Statements
In programming, an if/else statement is how we tell a computer to make a decision.
- If the condition is met (meaning you type
yesin the box), the computer will execute the first block of code and progress to the next step. - Else (meaning you type anything else), the computer executes the second block of code, which will stubbornly throw an error until it gets the answer it wants.
/* Excellent. Level 1 cleared. Now, initialize the date parameter. */
// PROMPT: Select your preferred execution day
const preferredDay =
;
compileItinerary(preferredDay);
Documentation: Variables
A variable is like a container that holds a specific value.
- Here we are declaring a variable named
preferredDayand assigning it the value of your choice from the dropdown. - Once selected, the
compileItineraryfunction will take that variable into the final step to build our plans!
> Executing Level 2 Itinerary... [OK]
Theme: The Classic Dinner & A Movie
📅 Date:
TBD
🍔 5:00 PM:
Dinner @ Murphy's Irish Bistro
// A comfortable distance for another lovely summer night walk
🍿 6:30 PM:
"Spider-Man: Brand New Day" @ The Davis
🍺 8:45 PM:
Post-Movie Drinks @ Dovetail Brewery
// Can't wait.
// - Adam
// - Adam
Documentation: Storing & Using User Input
When you selected a day in the previous step, we stored that user input into the computer's memory (our preferredDay variable).
- By storing data dynamically, programs can remember your choices and reuse them anywhere.
- Notice how the date in the itinerary above automatically updated to match your selection. It will also be injected straight into the text message below. That's the magic of storing state!
// Final step: Confirm compilation with developer
Send Adam a "Yes"