|
|
Q1618 Can swtch statements in JavaScript apply to a range of values?
irt.org | Knowledge Base | JavaScript | General | Q1618 [ previous next ] Q1618 Can swtch statements in JavaScript apply to a range of values?Yes, just omit the break statement and the case statements will all invoke the code up to the next break statement. In the following example, the text 1-5 will be output for any number from 1 to 5, and likewise for 6-10:
Alex Vincent writes: Found a better way to make switch statements apply for ranges.
Feedback on 'Q1618 Can swtch statements in JavaScript apply to a range of values?' |
-- div -->
|