One of the most powerful patterns in programming is declaring a variable first, then assigning different values to it based on conditions.
In this example, we will ask the user for their device battery percentage, and give advice based on the battery level. Pay special attention to how the action variable is first declared, and then assigned values based on conditions.
Couldn't we just declare and initialize the action variable within the condition blocks by writing let action = ...;? The answer is no, and we will see why in the next lesson.
Output (Console)