One Pager Cheat Sheet
- We will learn about controlling the behavior of a program using
if/elseandtry/catchstatements to establish itscontrol flow. - The control flow of a program is the order of execution of code elements, taking different decisions based on
if/elseandtry/catchstatements to handle errors and exceptions. If/Else Statementsprovide a way to control program execution, by defining different flows depending on the conditions, such as in the form of aflow chart diagram.- Using the
ifandelsekeywords, JavaScript allows for conditions to be evaluated with the syntaxif (expression) { statement; }, enabling developers to create ascopewithin thecurly bracesfor thestatementto be evaluated against the givenexpression. - We can use the
if-else if-elsestructure to determine a number's value in JavaScript using multipleifstatements. - An
ifcondition is essential forelse ifandelsestatements to work, but it is possible to have anifcondition that stands alone. - There is
no limitto the number of statements that can be included under anifblock. - The code needs a
boolean expressionenclosed in round brackets( )in theifblock in order to be evaluated by the compiler. - Using
try/catchstatements allow the programmer to handle errors that occur during the execution of the program. - Using the
tryandcatchkeywords, a JavaScript program can handle errors by running the statements in thecatchblock, preventing the program from halting. - No, we cannot have a
catchblock without atryblock because it is a syntax structure in JavaScript that requires both. - The
tryblock will attempt to execute the return statement, producing the output of 1 and thecatchblock will never be used as there was noerrorto handle. - We can control the flow of execution in a program and adapt to uncertain conditions using
if/elseandtry/catchstatements, which is necessary for many complex applications such as in artificial intelligence.

