Loading ...
Sorry, an error occurred while loading the content.

Re: Switch Case Style

Expand Messages
  • paperlampshade
    Works great! Thanks very much.
    Message 1 of 6 , Feb 4, 2013
    • 0 Attachment
      Works great! Thanks very much.

      --- In jslint_com@yahoogroups.com, "douglascrockford" wrote:
      >
      > --- In jslint_com@yahoogroups.com, "paperlampshade" wrote:
      > >
      > > Hi,
      > > I have a question about Switch Case style as verified in jslint.A switch
      > > case written as below (case statement starting on the line after the
      > > switch statement) will give many errors regarding the expected position
      > > from line "case 1:" to line "output = "";".
      > > var test = function (input) { 'use strict'; var output; switch
      > > (input) { case 1: output = "a"; break;
      > > case 2: output = "b"; break; case 3:
      > > output = "c"; break; default: output = "";
      > > } return output;};
      > > However when the same statement is written with the "case 1:" statement
      > > beginning one space after the switch "{" and the closing "}" one space
      > > from the "output = "";" line, there is no errors found.Example below:
      > > var test = function (input) { 'use strict'; var output; switch
      > > (input) { case 1: output = "a"; break; case
      > > 2: output = "b"; break; case 3:
      > > output = "c"; break; default: output = "";
      > > } return output;};
      > > Why is it important to have switch case syntax as in the second example?
      >
      >
      > Thanks. Please try it now.
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.