?Describe the structure of theif elsestatement.

What will be an ideal response?


?Theifstatement runs a command or a command block only if the conditional expression returns the valuetrue; it does nothing if the condition is false. On some occasions, a user might want to choose between alternate command blocks so that one command block is run if the conditional expression is true, and a different command block is run if the expression is false. The general structure of anifelse statement follows:?if (condition) {commands if condition is true} else {commands if condition is false}?If only a single command is run in response to theifstatement, one can use the following abbreviated form:
if (condition) command if condition is trueelse command if condition is false;?The following example shows anifelse statement that displays two possible alert boxes depending on whether the value of the day variable is Friday or not:
if (day === "Friday") alert("Thank goodness it's Friday")else alert("Today is " + day);?Likeifstatements,ifelsestatements can be nested as in the following code, which chooses between three possible alert boxes:
if (day === "Friday") alert("Thank goodness it's Friday")else {if (day === "Monday") alert("Blue Monday")else alert("Today is " + day);}?Some programmers advocate always using curly braces even if the command block contains only a single command. This practice visually separates oneelseclause from another. Also, when reading through nested statements, it can be helpful to remember that anelseclause usually pairs with the nearest precedingifstatement.

Computer Science & Information Technology

You might also like to view...

The ________ is (are) a set of suggestions on how to make your Web site more accessible and is (are) divided into a three-tier structure of checkpoints according to priority.

(a) World Wide Web Consortium (W3C). (b) Web Accessibility Initiative (WAI). (c) Web Content Accessibility Guidelines (WCAG). (d) WCAG’s Quicktips.

Computer Science & Information Technology

When you share a computer, to ensure thatno one else who uses that computer has access to your files, you should _____ before shutting down the system.

A. ?move all files to the root directory B. ?sign out of Windows 10 C. ?copy all files to the root directory D. ?connect the system to another Windows 10 device

Computer Science & Information Technology

?When more than one value is provided for the font-family property, the additional values are called _____ values.

A. ?fallback B. ?supplementary C. ?rollover D. ?add-on

Computer Science & Information Technology

Which of the following policies often contains clauses that permit a social networking operator to collect and store data on users or even share it with third parties?

a. Terms of Trade policy b. Terms of Use policy c. Terms of Endearment policy d. Terms of Retention policy

Computer Science & Information Technology