11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

}<br />

case 'D': alert("Not so good.");<br />

deansList = false;<br />

academicProbation = true;<br />

break;<br />

case 'F': alert("Back to the books.");<br />

deansList = false;<br />

academicProbation = true;<br />

break;<br />

default: alert("Grade Error!");<br />

<strong>The</strong> next aspect of switch to be aware of is that ―fall through‖ actions occur when you omit a<br />

break. You can use this feature to create multiple situations that produce the same result.<br />

Consider a rewrite of the previous example that performs similar actions if the grade is A or B,<br />

as well as D or F:<br />

var yourGrade='B';<br />

var deansList = false;<br />

var academicProbation = false;<br />

switch (yourGrade)<br />

{<br />

case 'A':<br />

case 'B': alert("Pretty good.");<br />

deansList = true;<br />

break;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!